ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Metafun textext()
Date: Fri, 11 Jan 2013 01:01:45 +0100	[thread overview]
Message-ID: <50EF5669.9020705@wxs.nl> (raw)
In-Reply-To: <alpine.DEB.2.02.1301100811480.5047@nqv-guvaxcnq>

[-- 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
___________________________________________________________________________________

  reply	other threads:[~2013-01-11  0:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10 11:48 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 [this message]
2013-01-10 13:29     ` Alan BRASLAU

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=50EF5669.9020705@wxs.nl \
    --to=pragma@wxs.nl \
    --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).