How to do a gradient in Postscript Re: [Open-graphics] Linux
Tag 2007 [Poster-Preview]
James Richard Tyrer
tyrerj at acm.org
Sat Mar 3 17:04:10 EST 2007
James Richard Tyrer wrote:
> Dieter wrote:
>>> But does postscript support the same types of gradients that SVG
>>> does?=20
>>> SVG lets you make pretty complex gradients, and while the PS version
>>> of=20
>>> the poster does have some kind of gradient, it's not the same as the=20
>>> SVG version. So either there's a bug in the conversion, or PS just=20
>>> doesn't support complex gradients.
>>
>> I don't know what you mean by "complex gradients". My copy of the red
>> book
>> has wandered off, but PS is a full blown programming language, so I
>> imagine
>> it can do what you want.
>>
>> Taking a quick glance at the wikipedia SVG page, looks like someone
>> decided
>> to create yet another graphics language, a couple of browsers have
>> partial
>> support, Adobe will drop support in less than a year, yadda yadda
>> yadda...
>>
>> The final output is supposed to be a large piece of paper, right? What
>> language(s) does the printer speak? Probably not SVG.
>
> It appears that a ShadingType 2 has built in support for extending
> beyond the end points like InkScape does.
What InkScape calls "None" and SVG calls "pad" is not the default for
PS. it requires this to be stated:
/Extend [true true]
> It appears (page 266 & 267 PLRM) that a ShadingType 2 dictionary can
> include a function definition. If none is defined,
Actually, you always have to define a function -- see below.
> then a linear
> shading is used, however, you should be able to define a f(t) do do
> whatever you want.
>
So, for the Green G quoting from IS's PS output:
<<
/ShadingType 2
/ColorSpace /DeviceRGB
/Coords [2338.1521 277.10916 2357.165 266.13211]
/Extend [true true]
/Domain [0 1]
/Function <<
/FunctionType 3
/Functions
[
<<
/FunctionType 2
/Domain [0 1]
/C0 [0 0.67843139 0.14509805]
/C1 [1 1 1]
/N 1
>>
]
/Domain [0 1]
/Bounds [ ]
/Encode [ 0 1 ]
>>
>>
PS will not simply repeat or reflect a gradient (it will only "Extend".
The gradient must be defined over the full extent of the shading. So,
in this case, you would need to change:
/Coords [2319.1392 288.08621 2376.1779 255.15506]
which is the simple part -- this does work.
The hard part is to then define a function for the color that will
provide the needed color over this new interval.
Does anyone actually know PostScript, this would be faster. :-D
IAC, the function needs to go from White to Green to White to Green
rather than from Green to White as it is now.
--
JRT
More information about the Open-graphics
mailing list