[NTG-context] TikZ and wrong drawing order

Mojca Miklavec mojca.miklavec.lists at gmail.com
Sun Jun 14 23:26:11 CEST 2015


On Fri, Jun 12, 2015 at 12:45 AM, Hans Hagen wrote:
>
> Most shades look ugly and useless to me anyway but you have more control
> than you think (always had but nicer interfaced in mpiv):
>
> \startMPpage
>     fill fullcircle scaled 10cm
>         withshademethod "circular"
>         withshadevector (5cm,1cm)
>         withshadecenter (.1,.5)
>         withshadedomain (.2,.6)
>         withshadefactor 1.2
>         withshadecolors (red,green)
>     ;
> \stopMPage

Great, I love the new syntax (compared to the MKII "ugliness" of shadings).

But how does one declare more than one colour? In particular, how
would you do the following in MP?

\usemodule
    [tikz]

\pgfdeclareverticalshading{rainbow}{100bp}{
    color(0bp)=(red);
    color(25bp)=(red);
    color(35bp)=(yellow);
    color(45bp)=(green);
    color(55bp)=(cyan);
    color(65bp)=(blue);
    color(75bp)=(violet);
    color(100bp)=(violet)}

\starttext
\starttikzpicture[shading=rainbow]
\shade[shading angle=90] (0,0) rectangle +(10,1);
\stoptikzpicture
\stoptext

> Of course you need to play with the values as there is no 'best'
> combination.

This is how TikZ defines the ball:

\pgfdeclareradialshading[tikz at ball]{ball}{\pgfqpoint{-10bp}{10bp}}{%
 color(0bp)=(tikz at ball!15!white);
 color(9bp)=(tikz at ball!75!white);
 color(18bp)=(tikz at ball!70!black);
 color(25bp)=(tikz at ball!50!black);
 color(50bp)=(black)}

Your example uses just two colours, while TikZ uses five and I don't
know how to translate this "ball shading" to MP (I know or at least
knew how to do it in plain PostScript and could dig it up; I think it
uses function shading with predefined colours at predefined distances,
but it's all a single shading (a single function), not a composition
of multiple sections).

Mojca


More information about the ntg-context mailing list