ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Mojca Miklavec" <mojca.miklavec.lists@gmail.com>
Subject: Re: metafun & \sometxt: should black be "black" or "textcolor"?
Date: Sun, 6 Aug 2006 19:02:53 +0200	[thread overview]
Message-ID: <6faad9f00608061002k249ed9f6t659abfd24fe36fc7@mail.gmail.com> (raw)
In-Reply-To: <44D5FEBB.8020808@elvenkind.com>

On 8/6/06, 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,

What a pitty that metapost wasn't one of Knuth's programs ;)

> 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 ;-)

Well, now to be honest: color "zero" (not "0 setgray", but the first
color in Gnuplot) is not supposed to be black, but should be
"foreground color" according to the guidelines (not that other divices
are configurable in that respect, but anyway). So it might indeed make
more sense to inherit the "textcolor". What do you think?

I spotted the problem when I was using a dark background with white
text on it. I'm not sure if I indeed want black or not. I want to make
the colors configurable anyway (which they're currently not, but I
have to figure out how to do that first), probably with something like
    \defineconversion[color set x][white,red,yellow,green]
    \setupGNUPLOT[colorset=color set x]
    % or perhaps even something like "foregroundcolor|maincolor=white"

So I actually liked the fact that the numbers on the plot were white
without having to configure anything (red and green were clearly seen
on the background), but the plot as a whole was useless since the
borders were still black & invisible and on some plots some text was
black as well (in a pseudo random way).

So rather than using that hack I would prefer to ask: which color
should I define in the module to make the border of the same color as
"textcolor"? Or (a question for later, it's not on the top priority
right now): how can I extract the color from
\setupGNUPLOT[foregroundcolor=yellow] and store it to a variable
"color gp_foregroundcolor;" defined in a module?

Any other thoughts about it?

> > A question for you or Hans: can please someone explain me in a few
> > words what's the main strategy/philosophy behind \sometxt. I don't
> > understand exactly how TeX processes it (and metapost
> > shrinks/expands/shifts/colors) it inline.
>
> TeX typesets the argument of the \sometxt macro in a hbox and
> writes its box dimensions to <jobname-mpgraph.mpb>.
>
> To the metapost file, a zero-padded serial number is written
> instead, and MP uses the dimensions it finds in <jobname-mpgraph.mpb>
> for the positioning of that label.
>
> ConTeXt then replaces the metapost label number with the TeX material
> while interpreting the Metapost result.
>
> This is the short version, the actual situation is a little bit more
> complex (not a whole lot though). The actual code is in meta-tex.tex
> and mp-txts.mp

Thanks for the wonderful explanation!

Thank you again,
    Mojca

  reply	other threads:[~2006-08-06 17:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-06  2:32 Mojca Miklavec
2006-08-06  8:52 ` Taco Hoekwater
2006-08-06 11:26   ` Mojca Miklavec
2006-08-06 14:37     ` Taco Hoekwater
2006-08-06 17:02       ` Mojca Miklavec [this message]
2006-08-06 21:48       ` Hans Hagen
2006-08-06 22:02       ` Hans Hagen
2006-08-07  8:04         ` Mojca Miklavec
2006-08-07  8:15           ` Taco Hoekwater
2006-08-07  9:40             ` Mojca Miklavec
2006-08-07 10:25               ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6faad9f00608061002k249ed9f6t659abfd24fe36fc7@mail.gmail.com \
    --to=mojca.miklavec.lists@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).