From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/30052 Path: news.gmane.org!not-for-mail From: "Mojca Miklavec" Newsgroups: gmane.comp.tex.context Subject: Re: metafun & \sometxt: should black be "black" or "textcolor"? Date: Mon, 7 Aug 2006 10:04:31 +0200 Message-ID: <6faad9f00608070104o40c3041cq70c6666ab3179090@mail.gmail.com> References: <6faad9f00608051932ie703df0j94c670536a0f156f@mail.gmail.com> <44D5ADBE.3010809@elvenkind.com> <6faad9f00608060426g7d389fb4k803f2725f02ceef3@mail.gmail.com> <44D5FEBB.8020808@elvenkind.com> <44D666E7.5000400@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1154937890 21571 80.91.229.2 (7 Aug 2006 08:04:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 7 Aug 2006 08:04:50 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Mon Aug 07 10:04:49 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1GA06T-0002Ad-4f for gctc-ntg-context-518@m.gmane.org; Mon, 07 Aug 2006 10:04:49 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id CF9411FF5C; Mon, 7 Aug 2006 10:04:48 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 06425-02-3; Mon, 7 Aug 2006 10:04:39 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 2820F2001A; Mon, 7 Aug 2006 10:04:39 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 018AB2001D for ; Mon, 7 Aug 2006 10:04:35 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 06425-02-2 for ; Mon, 7 Aug 2006 10:04:31 +0200 (CEST) Original-Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by ronja.ntg.nl (Postfix) with SMTP id D7E022001A for ; Mon, 7 Aug 2006 10:04:31 +0200 (CEST) Original-Received: by nf-out-0910.google.com with SMTP id x29so914543nfb for ; Mon, 07 Aug 2006 01:04:31 -0700 (PDT) Original-Received: by 10.78.117.10 with SMTP id p10mr2314517huc; Mon, 07 Aug 2006 01:04:31 -0700 (PDT) Original-Received: by 10.78.175.15 with HTTP; Mon, 7 Aug 2006 01:04:31 -0700 (PDT) Original-To: "mailing list for ConTeXt users" In-Reply-To: <44D666E7.5000400@wxs.nl> Content-Disposition: inline X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:30052 Archived-At: On 8/7/06, Hans Hagen wrote: > Taco Hoekwater wrote: > > Hi Mojca, > > > > Mojca Miklavec wrote: > > > >> But the other \sometxt was indeed red - withcolor seems to work, but > >> only conditionally. And I have some weird examples of two texts one > >> after another. In some cases (if something else is drawn inbetween and > >> a color changed twice), then the second text will be black. But it's > >> quite unpredictable (that one might even be bug in my code, so I don't > >> want to complain before I have an example). > >> > > > > Ok, I looked into this again, and I was definately wrong. > > > > The actual problem appears to be that metapost does not write a > > color switch for 'black' when it appears at the start of a file, > > it simply assumes the start color is black. This could be > > considered a bug in MetaPost or a missing feature in ConTeXt > > (i have not decided yet :-)). > > > > Quick fix: You can start your MP code with an explicit color > > initialization. > > > > \startMPcode > > special "0 setgray"; > > ...... > > \stopMPcode > > > > > > A hack, I know. MetaPost should be able to distinguish between > > draw p > > and > > draw p withcolor (0,0,0) > > but currently it can't (because the structure is initialized > > as (0,0,0)). It is not quite a bug either, because there may > > well be MP code out there that depends on this. > > In fact, probably code by Knuth, Hobby, Jacko, and Hans ;-) > > > > > in meta-pdf.tex: > > \chardef\blackoutMPgraphic\plusone > > \def\finishMPgraphic > {\stopMPresources > \egroup > \setbox\scratchbox\vbox > {\forgetall > \hbox > {\PDFcode{q \MPxscale\space 0 0 \MPyscale\space \MPxoffset\space \MPyoffset\space cm}% > \ifcase\blackoutMPgraphic\or\PDFcode{0 g 0 G}\fi > \lower\MPyshift\box\scratchbox % unscaled shift > \PDFcode{Q}}}% > \ht\scratchbox\MPheight > \wd\scratchbox\MPwidth > \dp\scratchbox\zeropoint\relax > \dopackageMPgraphic\scratchbox > \egroup > \endinput} > > > \starttext > > \color[red]{\startMPcode > draw fullcircle scaled 5cm ; > draw btex test etex ; > \stopMPcode red} > > \startreusableMPgraphic{test} > draw fullcircle scaled 5cm ; > draw btex test etex ; > \stopreusableMPgraphic > > \color[red]{red \reuseMPgraphic{test} red} > > \stoptext Thanks! This indeed solves the problem. However, I'm not sure any more whether blackoutMPgraphic should be true or false by default. One of my old files (when I was learning metapost from the manual): def star (expr size, n, pos) = for a=0 step 360/n until round(360*(1-1/n)) : draw (origin -- (size/2,0)) rotatedaround (origin,a) shifted pos ; endfor ; enddef ; beginfig(803) ; pickup pencircle scaled 2mm ; star(2cm,5,origin) ; endfig ; -------------------------------- \useexternalfigure[pentastar][star.803][height=4cm] \starttext \placefigure {A five||point star drawn by \METAPOST.} {\color[green]{\externalfigure[pentastar]}} % I wanted it to be green \stoptext -------------------------------- I tried that one once more because I remember that I was very happy to be able to color the star from outside without modifying the figure itself (I didn't use any explicit color to make it black though). I don't mind it either way (now that I know how to switch it on or off), but I'm not sure if there are not other people using the same trick as well. The "real problem" appears in the following figure where the first black is ignored and the second one is not, so it's rather inconsistent: \setupcolors [state=start,textcolor=blue] \chardef\blackoutMPgraphic 0 \starttext \startMPcode draw \sometxt{blue} withcolor black; draw \sometxt{red} shifted (1.5cm,0) withcolor red; draw \sometxt{black} shifted (3cm,0) withcolor black; \stopMPcode \stoptext I can image a "fair solution" to draw "withcolor black" in black and to let the parts with no explicit color and an empty drawoptions() string to use the "default color" (perhaps with gsave/grestore). But I'm not entitled to judge about it. In any case I'll have to use a solution which will not depend on this behaviour. Is there any chance to get "withcolor somecolor", where "somecolor" is the color set with "textcolor=somecolor"? Thanks a lot, Mojca