shading with stitching functions
![](https://secure.gravatar.com/avatar/6114858d84b0f40cf715f12237ab67a1.jpg?s=120&d=mm&r=g)
Hello, I'm still trying to get shading in MetaPost as the one in the attached eps file, but I don't manage to decipher the way how other shandings are done. There's a .tex file attached with a failed (hardcoded) example tries ... but I don't know where to explore further. I would appreciate any hints, Mojca
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
Mojca Miklavec wrote:
Hello,
I'm still trying to get shading in MetaPost as the one in the attached eps file, but I don't manage to decipher the way how other shandings are done.
There's a .tex file attached with a failed (hardcoded) example tries .... but I don't know where to explore further. well, 'where' coul dbe spec-tpd, or the pdftex manual -)
{\immediate\pdfobj stream attr {/FunctionType 0 /Order 1 /BitsPerSample 8 /Domain [\gMPs1 \gMPs2] /Decode [ 0 1 0 1 0 1 ] /Range [ 0 1 0 1 0 1 ] /Size [ 11 ]} {00 00 00 51 00 96 71 02 f3 8c 07 f3 a1 10 96 b4 20 00 c6 37 00 d5 57 00 e4 83 00 f2 ba 00 ff ff 00}% you can try to define a stream but then you also must maks sure that there is a corresponding length key Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/44ca9eda7aaa681c0e3b3e90125c56b0.jpg?s=120&d=mm&r=g)
Hi Mojca, this is also on my wishlist (and christmas is over). Currently I use several color gradients in a row, to simulate the same effect. But sadly this way is too viewer dependent (rendering is a matter of luck with every new version), not to mention the big size. So if there would be a cleaner solution, I would be a happy man. I'm willing to help, but I haven't looked into specials yet. Give me some time for reading and some more time for understanding... ;) Greetings, Peter Mojca Miklavec wrote:
Hello,
I'm still trying to get shading in MetaPost as the one in the attached eps file, but I don't manage to decipher the way how other shandings are done.
There's a .tex file attached with a failed (hardcoded) example tries ... but I don't know where to explore further.
I would appreciate any hints, Mojca
------------------------------------------------------------------------
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
![](https://secure.gravatar.com/avatar/6114858d84b0f40cf715f12237ab67a1.jpg?s=120&d=mm&r=g)
On 12/27/06, Peter Rolf wrote:
Hi Mojca,
this is also on my wishlist (and christmas is over). Currently I use several color gradients in a row, to simulate the same effect. But sadly this way is too viewer dependent (rendering is a matter of luck with every new version), not to mention the big size. So if there would be a cleaner solution, I would be a happy man.
I'm willing to help, but I haven't looked into specials yet. Give me some time for reading and some more time for understanding... ;)
With Hans's hint I finally got some kind of result. However, the numbers in the stream seem to influence the colors, but not in the way I want them to. I have to do some further explorations. Does anyone know how to convert PS to PDF without compression? Btw: TikZ supports such shadings, so if you don't necessary need a metapost graphic, you can take a look at it as well. Here's an example from the manual: \usemodule[tikz] \starttext \pgfdeclarehorizontalshading{myshadingA} {1cm}{rgb(0cm)=(1,0,0); color(2cm)=(green); color(4cm)=(blue)} \pgfuseshading{myshadingA} \stoptext (I've just found out that it uses another aproach for "sampled functions", perhaps I'll have more chances to figure out how to implement it that way.) Mojca
![](https://secure.gravatar.com/avatar/44ca9eda7aaa681c0e3b3e90125c56b0.jpg?s=120&d=mm&r=g)
Mojca Miklavec wrote:
On 12/27/06, Peter Rolf wrote:
Hi Mojca,
this is also on my wishlist (and christmas is over). Currently I use several color gradients in a row, to simulate the same effect. But sadly this way is too viewer dependent (rendering is a matter of luck with every new version), not to mention the big size. So if there would be a cleaner solution, I would be a happy man.
I'm willing to help, but I haven't looked into specials yet. Give me some time for reading and some more time for understanding... ;)
With Hans's hint I finally got some kind of result. However, the numbers in the stream seem to influence the colors, but not in the way I want them to. I have to do some further explorations. Does anyone know how to convert PS to PDF without compression?
I used \pdfcompresslevel=0 with your example code.
Btw: TikZ supports such shadings, so if you don't necessary need a metapost graphic, you can take a look at it as well. Here's an example
from the manual:
I need them as mp graphic, but it shouldn't hurt to look into that.
\usemodule[tikz] \starttext \pgfdeclarehorizontalshading{myshadingA} {1cm}{rgb(0cm)=(1,0,0); color(2cm)=(green); color(4cm)=(blue)} \pgfuseshading{myshadingA} \stoptext
(I've just found out that it uses another aproach for "sampled functions", perhaps I'll have more chances to figure out how to implement it that way.)
Mojca _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
participants (3)
-
Hans Hagen
-
Mojca Miklavec
-
Peter Rolf