* Metafun textext()
@ 2013-01-10 11:48 Alan BRASLAU
2013-01-10 11:51 ` Aditya Mahajan
0 siblings, 1 reply; 7+ messages in thread
From: Alan BRASLAU @ 2013-01-10 11:48 UTC (permalink / raw)
To: mailing list for ConTeXt users
Metafun textext() has been changed in an attempt to be more efficient. However, this has a side effet that it now handles colors differently, among other things. The following example, intended to cause difficulties for the color blind, no longer works. Is this a bug or a feature?
\starttext
\startMPcode
picture T ;
T := thelabel(textext("I'm seeing double"),origin) ;
draw T withcolor green ;
draw T shifted (-1mm,1mm) withcolor blue ;
\stopMPcode
\stoptext
Alan
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Metafun textext()
2013-01-10 11:48 Metafun textext() Alan BRASLAU
@ 2013-01-10 11:51 ` Aditya Mahajan
2013-01-10 13:01 ` Alan BRASLAU
0 siblings, 1 reply; 7+ messages in thread
From: Aditya Mahajan @ 2013-01-10 11:51 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Thu, 10 Jan 2013, Alan BRASLAU wrote:
> Metafun textext() has been changed in an attempt to be more efficient.
> However, this has a side effet that it now handles colors differently,
> among other things. The following example, intended to cause
> difficulties for the color blind, no longer works. Is this a bug or a
> feature?
>
> \starttext
> \startMPcode
> picture T ;
> T := thelabel(textext("I'm seeing double"),origin) ;
>
> draw T withcolor green ;
> draw T shifted (-1mm,1mm) withcolor blue ;
> \stopMPcode
> \stoptext
Since the beginning of MkIV, colors in metapost labels need to be set at
the ConTeXt end (Untested):
T := thelabel(textext("\color[blue]{I'm seeing double}"), origin);
Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Metafun textext()
2013-01-10 11:51 ` Aditya Mahajan
@ 2013-01-10 13:01 ` Alan BRASLAU
2013-01-10 13:17 ` Mojca Miklavec
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Alan BRASLAU @ 2013-01-10 13:01 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Thu, 10 Jan 2013 06:51:50 -0500
Aditya Mahajan <adityam@umich.edu> wrote:
> Since the beginning of MkIV, colors in metapost labels need to be set at
> the ConTeXt end (Untested):
>
> T := thelabel(textext("\color[blue]{I'm seeing double}"), origin);
>
> Aditya
I don't believe that this is true, but I am most likely wrong.
Indeed "\blue text" has worked, but 'draw T withcolor blue;' *should* work as well.
The processing of textext() has changed recently, it seems.
\startMPcode
label(textext("I'm seeing double"),origin) withcolor green ;
label(textext("I'm seeing double"),(-1mm,1mm)) withcolor blue ;
\stopMPcode
DOES work.
Of course, these are much simplified minimal examples of what I would like to do.
Alan
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Metafun textext()
2013-01-10 13:01 ` Alan BRASLAU
@ 2013-01-10 13:17 ` Mojca Miklavec
2013-01-10 13:18 ` Aditya Mahajan
2013-01-10 13:29 ` Alan BRASLAU
2 siblings, 0 replies; 7+ messages in thread
From: Mojca Miklavec @ 2013-01-10 13:17 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Thu, Jan 10, 2013 at 2:01 PM, Alan BRASLAU wrote:
> On Thu, 10 Jan 2013 06:51:50 -0500
> Aditya Mahajan wrote:
>
>> Since the beginning of MkIV, colors in metapost labels need to be set at
>> the ConTeXt end (Untested):
>>
>> T := thelabel(textext("\color[blue]{I'm seeing double}"), origin);
>>
>> Aditya
>
> I don't believe that this is true, but I am most likely wrong.
Based on a snippet from mp-gnuplot (and agreeing with your point of
view that it would be nice if it worked without the extra hassle) I
tend to agree with Aditya (and I seem to remember that Hans
implemented \colored[r=...,g=...,b=...] command exactly when this
became a problem):
% Returns an image with colored text according to current color
% This only makes sense for mkiv text. Mkii is handled with \sometxt
% and colors are working properly there. /.../
vardef gp_colored_mkiv_text(expr str) =
% since withcolor doesn't work any more, we need to provide a workaround.
save r, g, b;
r = redpart gp_color_current;
g = greenpart gp_color_current;
b = bluepart gp_color_current;
rawtextext("\colored[r=" & decimal(r) & ",g=" & decimal(g) & ",b="
& decimal(b) & "]{" & str & "}")
enddef;
Mojca
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Metafun textext()
2013-01-10 13:01 ` Alan BRASLAU
2013-01-10 13:17 ` Mojca Miklavec
@ 2013-01-10 13:18 ` Aditya Mahajan
2013-01-11 0:01 ` Hans Hagen
2013-01-10 13:29 ` Alan BRASLAU
2 siblings, 1 reply; 7+ messages in thread
From: Aditya Mahajan @ 2013-01-10 13:18 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Thu, 10 Jan 2013, Alan BRASLAU wrote:
> On Thu, 10 Jan 2013 06:51:50 -0500
> Aditya Mahajan <adityam@umich.edu> wrote:
>
>> Since the beginning of MkIV, colors in metapost labels need to be set at
>> the ConTeXt end (Untested):
>>
>> T := thelabel(textext("\color[blue]{I'm seeing double}"), origin);
>>
>> Aditya
>
> I don't believe that this is true, but I am most likely wrong.
Well, I think it was true in the beginning (as I remember a discussion
from Mojca on how to handle labels differently in the gnuplot module),
but clearly that is not the case now.
> Indeed "\blue text" has worked, but 'draw T withcolor blue;' *should* work as well.
> The processing of textext() has changed recently, it seems.
>
> \startMPcode
> label(textext("I'm seeing double"),origin) withcolor green ;
> label(textext("I'm seeing double"),(-1mm,1mm)) withcolor blue ;
> \stopMPcode
>
> DOES work.
>
> Of course, these are much simplified minimal examples of what I would like to do.
Minimal example to show what is happening:
\startbuffer[initialize]
picture T;
T := textext("Hello");
picture Q;
Q := T;
\stopbuffer
\startbuffer[T]
draw T withcolor blue;
\stopbuffer
\startbuffer[Q]
draw Q shifted (-1mm, 1mm) withcolor red;
\stopbuffer
\startlines
Only draw T: \processMPbuffer[initialize,T]
Only draw Q: \processMPbuffer[initialize,Q]
Draw T & Q : \processMPbuffer[initialize,T,Q]
Draw Q & T : \processMPbuffer[initialize,Q,T]
\stoplines
Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Metafun textext()
2013-01-10 13:01 ` Alan BRASLAU
2013-01-10 13:17 ` Mojca Miklavec
2013-01-10 13:18 ` Aditya Mahajan
@ 2013-01-10 13:29 ` Alan BRASLAU
2 siblings, 0 replies; 7+ messages in thread
From: Alan BRASLAU @ 2013-01-10 13:29 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Thu, 10 Jan 2013 14:01:14 +0100
Alan BRASLAU <alan.braslau@cea.fr> wrote:
> \startMPcode
> label(textext("I'm seeing double"),origin) withcolor green ;
> label(textext("I'm seeing double"),(-1mm,1mm)) withcolor blue ;
> \stopMPcode
>
> DOES work.
TESTED!
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Metafun textext()
2013-01-10 13:18 ` Aditya Mahajan
@ 2013-01-11 0:01 ` Hans Hagen
0 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2013-01-11 0:01 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 3581 bytes --]
On 1/10/2013 2:18 PM, Aditya Mahajan wrote:
> On Thu, 10 Jan 2013, Alan BRASLAU wrote:
>
>> On Thu, 10 Jan 2013 06:51:50 -0500
>> Aditya Mahajan <adityam@umich.edu> wrote:
>>
>>> Since the beginning of MkIV, colors in metapost labels need to be set at
>>> the ConTeXt end (Untested):
>>>
>>> T := thelabel(textext("\color[blue]{I'm seeing double}"), origin);
>>>
>>> Aditya
>>
>> I don't believe that this is true, but I am most likely wrong.
>
> Well, I think it was true in the beginning (as I remember a discussion
> from Mojca on how to handle labels differently in the gnuplot module),
> but clearly that is not the case now.
>
>> Indeed "\blue text" has worked, but 'draw T withcolor blue;' *should*
>> work as well.
>> The processing of textext() has changed recently, it seems.
The mkiv implementation has always been rather different from the mkii
one: text handling as well as dealing with colors.
>> \startMPcode
>> label(textext("I'm seeing double"),origin) withcolor green ;
>> label(textext("I'm seeing double"),(-1mm,1mm)) withcolor blue ;
>> \stopMPcode
>>
>> DOES work.
>>
>> Of course, these are much simplified minimal examples of what I would
>> like to do.
>
> Minimal example to show what is happening:
>
> \startbuffer[initialize]
> picture T;
> T := textext("Hello");
>
> picture Q;
> Q := T;
> \stopbuffer
>
> \startbuffer[T]
> draw T withcolor blue;
> \stopbuffer
>
> \startbuffer[Q]
> draw Q shifted (-1mm, 1mm) withcolor red;
> \stopbuffer
>
> \startlines
> Only draw T: \processMPbuffer[initialize,T]
> Only draw Q: \processMPbuffer[initialize,Q]
> Draw T & Q : \processMPbuffer[initialize,T,Q]
> Draw Q & T : \processMPbuffer[initialize,Q,T]
> \stoplines
You and Alan can pick up the beta from the ftp server and play with this:
\setupbodyfont[dejavu]
\starttext
\startMPpage[offset=10pt]
picture MyText ; MyText := textext("Dummy") ; % not used later on
picture MyText ; MyText := textext("\red Red") ;
draw MyText ;
draw MyText scaled 2 shifted (0,-1cm) ;
draw MyText scaled 3 shifted (0,-2cm) ;
picture MyText ; MyText := textext("Blue Green Red") ;
draw MyText rotatedaround(center MyText,10) shifted (0,-3cm)
withcolor blue ;
draw MyText shifted (0,-4cm) withcolor green ;
draw MyText rotatedaround(center MyText,-10) shifted (0,-5cm)
withcolor red ;
picture MyText ; MyText := image (
draw textext("Green Red Blue {\yellow YELLOW} Whatever 1") ;
draw textext("Green Red Blue {\yellow YELLOW} Whatever 2")
shifted (10cm,0) ;
) ;
draw MyText shifted (0,-6cm) withcolor green ;
draw MyText shifted (0,-7cm) withcolor red ;
draw MyText shifted (0,-8cm) withcolor blue ;
\stopMPpage
\stoptext
The complication is that we reuse a picture which once defined has
frozen properties. However, after hours of lua/tex juggling I managed to
made a variant that better keeps track of applied colors. I'm not sure
if this is foolproof but it's probably quite ok for what Alan wants to
do. Although ... being a scientist he will look for the next frontier
... (or even more scientific: try to prove me wrong).
Hans
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
[-- Attachment #2: textext-002.pdf --]
[-- Type: application/pdf, Size: 16483 bytes --]
[-- Attachment #3: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-01-11 0:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-10 11:48 Metafun textext() Alan BRASLAU
2013-01-10 11:51 ` Aditya Mahajan
2013-01-10 13:01 ` Alan BRASLAU
2013-01-10 13:17 ` Mojca Miklavec
2013-01-10 13:18 ` Aditya Mahajan
2013-01-11 0:01 ` Hans Hagen
2013-01-10 13:29 ` Alan BRASLAU
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).