ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: TikZ and wrong drawing order
Date: Mon, 15 Jun 2015 10:02:26 +0200	[thread overview]
Message-ID: <CALBOmsYoOKVAt-Ux=VNeUU_xANpNdDUzq_DPpYT8ajF3fO_t+Q@mail.gmail.com> (raw)
In-Reply-To: <557E822A.4090903@wxs.nl>

On Mon, Jun 15, 2015 at 9:43 AM, Hans Hagen wrote:
> On 6/14/2015 11:26 PM, Mojca Miklavec wrote:
>>
>> 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).
>
>
> well, even mkii could do some magic if one went a bit more low level

I know. The resulting PDF was great, but doing any programming in MkII
was a nightmare.

> shading is quite old actually (dates from before tikz showed up -)

TikZ is a relatively recent piece of software.

> i have in my mailbox a mail from 1999 from mathew that demos a function
> shading (some perl code) which is the way to go with more advanced shades
>
>> 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
>
>
> you're one of those people infected by apple software where shades are (of
> maybe were) the fashion

Actually, some shadings in PDF are broken in Apple's libraries. The
output of Asymptote (and some output of my own simulations) can
sometimes only be rendered properly by Acrobat, while Apple software
would simply crash or render pure nonsense.

> (next thing you will ask to simulate perkament
> behind your pages or leather looking cover pages) ... aka patterns in ps

Thanks for the idea ;)

>>> Of course you need to play with the values as there is no 'best'
>>> combination.
>>
>>
>> This is how TikZ defines the ball:
>>
>> \pgfdeclareradialshading[tikz@ball]{ball}{\pgfqpoint{-10bp}{10bp}}{%
>>   color(0bp)=(tikz@ball!15!white);
>>   color(9bp)=(tikz@ball!75!white);
>>   color(18bp)=(tikz@ball!70!black);
>>   color(25bp)=(tikz@ball!50!black);
>>   color(50bp)=(black)}
>
>
> that's mostly a shade made out of steps (in the pdf one shade operation but
> not better than 8 shades next to each other)

8 shades next to each other are probably less efficient and might
render with "holes" in non-Acrobat buggy renderers. But your example
below looks like it should be interpreted as a "single shading" (it
uses a single function), so it should work fine.

What is the decimal part (".00128") used for?

> ... personally i dislike such
> granular shaded (either do it good or don't do it at all)
>
> (btw in context code will look a bit more complex because we also need to
> deal with spot colors, multi-tones, cmyk, etc)
>
>> 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).
>
>
> something similar to
>
> <</Shading << /Sh <<
>   /ShadingType 2
>   /ColorSpace
>   /DeviceRGB
>   /Domain [0.0 100.00128]
>   /Coords [0 0.0 0 100.00128]
>   /Function <<
>     /FunctionType 3
>     /Domain [0.0 100.00128]
>     /Functions [
>       << /FunctionType 2 /Domain [0.0 100.00128] /C0 [1 0 0] /C1 [1 0 0] /N
> 1 >>
>       << /FunctionType 2 /Domain [0.0 100.00128] /C0 [1 0 0] /C1 [1 1 0] /N
> 1 >>
>       << /FunctionType 2 /Domain [0.0 100.00128] /C0 [1 1 0] /C1 [0 1 0] /N
> 1 >>
>       << /FunctionType 2 /Domain [0.0 100.00128] /C0 [0 1 0] /C1 [0 1 1] /N
> 1 >>
>       << /FunctionType 2 /Domain [0.0 100.00128] /C0 [0 1 1] /C1 [0 0 1] /N
> 1 >>
>       << /FunctionType 2 /Domain [0.0 100.00128] /C0 [0 0 1] /C1 [0 0 0] /N
> 1 >>
>       << /FunctionType 2 /Domain [0.0 100.00128] /C0 [0 0 0] /C1 [0 0 0] /N
> 1 >>
>     ]
>   /Bounds [ 25.00032 35.00043 45.00056 55.00069 65.00082 75.00096]
>   /Encode [0 1  0 1 0 1 0 1 0 1 0 1 0 1] >>
>   /Extend [false false]
>>> >>/ProcSet[/PDF] >>
>
> not too hard to program (if i can motivate myself)

Talking about old examples ... here's an example in pure PostScript
that achieves a desired result, including your response (however it
doesn't support specifying the locations of colours):
    http://www.ntg.nl/pipermail/ntg-context/2006/022833.html

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
___________________________________________________________________________________

  reply	other threads:[~2015-06-15  8:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 17:27 Mojca Miklavec
2015-06-11 17:59 ` Aditya Mahajan
2015-06-11 20:14   ` Mojca Miklavec
2015-06-11 20:43     ` Aditya Mahajan
2015-06-11 20:58       ` Mojca Miklavec
2015-06-11 21:26     ` Hans Hagen
2015-06-14 21:09       ` Mojca Miklavec
2015-06-11 21:12 ` Hans Hagen
2015-06-11 22:28   ` Mojca Miklavec
2015-06-11 22:45     ` Hans Hagen
2015-06-14 21:26       ` Mojca Miklavec
2015-06-14 21:38         ` Mojca Miklavec
2015-06-15  7:43         ` Hans Hagen
2015-06-15  8:02           ` Mojca Miklavec [this message]
2015-06-15 13:02             ` Hans Hagen
2015-06-15 13:36               ` Mojca Miklavec
2015-06-15  9:48           ` Alan BRASLAU
2015-06-15 11:47         ` Hans Hagen
2015-06-12  7:11     ` 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='CALBOmsYoOKVAt-Ux=VNeUU_xANpNdDUzq_DPpYT8ajF3fO_t+Q@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).