%!
100 100 moveto 100 500 lineto
3 setlinewidth
strokepath
<<
/ShadingType 2 /ColorSpace /DeviceRGB /Extend [true true]
/Function
<<
/FunctionType 0 /N 1 /Domain [0 1] /Range [0 1 0 1 0 1] /
Order 1 /Size [2]
/DataSource [
1 7 div 1 0.75 gsave sethsbcolor currentrgbcolor grestore 0
2 7 div 1 0.75 gsave sethsbcolor currentrgbcolor grestore 1
]
>>
/Coords [
500 200
500 400
]
>>
shfill
showpage
Thank you.
For a type 0 (sampled) function the DataSource is defined to be either a
string or a positionable file providing the sample data. You have
provided a PostScript procedure. This will raise a typecheck error.
For a Type 0 function you *must* supply a BitsPerSample value, which is
not present.
You cannot use a PostScript function as the basis for the data in a
Function dictionary.
Ken
But is it possible to convert computed PostScript-function data to
either of the formats allowed in a function dictionary? And if so,
please, how?
> But is it possible to convert computed PostScript-function data to
> either of the formats allowed in a function dictionary? And if so,
> please, how?
Run the PostScript functions on a number of potential input values to
generate the output data points. Take those data points, convert into
string data, supply the string as a DataSource to the type 0 Function.
Interpolation will generate the intermediate points. FOr more accuracy,
run more samples, cost is only more string data.
Ken
Converting to string: cvs
If you need a function for appending to an existing string, see
comp.lang.postscript faqs (7.8 How can I concatenate two strings
together?)
Thanks,
Olle
/ConcatenateOverflowErrorsSuppressed false def
/Concatenate
{
2 copy type exch type
2 copy /stringtype ne exch /stringtype ne or
{
2 copy /arraytype eq exch /arraytype eq 4 2 roll /packedarraytype eq
exch /packedarraytype eq
3 -1 roll or 3 1 roll or and not
{
(Error: Concatenate, types either unsuitable or non-matching)
OutputToLog == == stop
} {false} ifelse % not both arrays
} {pop pop true} ifelse % either not a string
3 1 roll 2 copy length exch length add dup 65535 le
{
4 -1 roll {string} {array} ifelse dup dup
0 5 index putinterval
4 -1 roll length 4 -1 roll putinterval
}
{
% bool A B joint-size
pop 3 -1 roll
{
1 index length 65535 ge
{
pop
ConcatenateOverflowErrorsSuppressed not
{
(Error: Concatenate, first string of maximal size. Suppressing
reporting of further such errors.) OutputToLog
/ConcatenateOverflowErrorsSuppressed true store
} if % ConcatenateOverflowErrorsSuppressed not
}
{
ConcatenateOverflowErrorsSuppressed not
{
(Error: Concatenate -- truncation, as objects jointly too long.
Suppressing reporting of further such errors.) OutputToLog
/ConcatenateOverflowErrorsSuppressed true store
} if % ConcatenateOverflowErrorsSuppressed not
65535 string dup dup % A B string string string
0 5 index putinterval % A B string string
4 -1 roll length dup 65535 exch sub % B string string |A| 65535-|
A|
5 -1 roll 0 3 -1 roll getinterval % string string |A| B'
dup length 0 gt {putinterval} {pop pop} ifelse % string
} ifelse % First object maximal length
dup 65532 (...) putinterval
}
{
ConcatenateOverflowErrorsSuppressed not
{
(Error: Concatenate, objects jointly too large, returning only
first object. Suppressing reporting of further such errors.)
OutputToLog
/ConcatenateOverflowErrorsSuppressed true store
} if % ConcatenateOverflowErrorsSuppressed not
pop
} ifelse % string
} ifelse % fits within architectural limits
} bind def % /Concatenate
Well, using cvs is pretty straightforward, you just have to check that
your argument is a number.
Something like this might work for you:
% integer/real *CeeVeeEss* string true
% other *CeeVeeEss* other false
/CeeVeeEss
{
dup type dup /integertype eq exch /realtype eq or
{20 string cvs true}{false}
ifelse
}
bind def
/ConcatenateOverflowErrorsSuppressed false def
/Concatenate
{
CeeVeeEss {( ) Concatenate} if exch
CeeVeeEss {( ) Concatenate} if exch
2 copy type exch type
...
If an argument was converted to a string a space will be appended to
it.
Thanks,
Olle
Why does the following give me a typecheck in shfill?
strokepath
<<
/ShadingType 2 /ColorSpace /DeviceRGB /Extend [true true]
/Function
<<
/FunctionType 0 /N 1 /Domain [0 1] /Range [0 1 0 1 0 1] /Order 1 /
Size [2]
/DataSource [(0.115385 0.75 0.0 0 0.115385 0.0 0.75 1 )]
>>
/Coords [814.958 553.151 814.958 289.594]
>>
shfill
Splitting the DataSource into two strings doesn't help: [(0.115385
0.75 0.0 0) ( 0.115385 0.0 0.75 1 )]
PS type1 shadings are functions which take two values from the stack and
push N values, one per colour component.
It seems better to use a type1 than to use ps code to create a string to
use with a type2 shading.
-JimC
--
James Cloos <cl...@jhcloos.com> OpenPGP: 1024D/ED7DAEA6
There is a path, consisting of a single curveto with the two internal
control points being the same, so the path not self-intersecting.
There are computed RGB values for the colours at the two ends. In
between I want the colour to shift gradually from one to the other,
and I don't care about the speed of colour variation.
Please, given real values X0 Y0 X1 Y1 X3 Y3, R0 G0 B0, R3 G3 B3, show
me the code that makes it happen.
The /DataSource is still an array. Try:
> > Splitting the DataSource into two strings doesn't help: [(0.115385
> > 0.75 0.0 0) ( 0.115385 0.0 0.75 1 )]
>
> The /DataSource is still an array. Try:
>
> /DataSource (0.115385 0.75 0.0 0 0.115385 0.0 0.75 1 )
In this case the data must be binary, not ASCII, eg:
<0001020304> = 0x01 0x02 0x03 0x04 etc
To map the integer hex values into the domain of the function output you
must supply a Decode array. Depending on the input, you may also find it
necessary to supply an Encode array as well.
Ken
Thank you. But, please, would it be easy to post some code that could
convert real variables R0 G0 B0 R3 G3 B3 into the appropriately-
formatted DataSource / Encode / BitsPerSample data?
I have plenty of spare memory so BitsPerSample could happily be large.
Unless that introduces new problems.
Note to self:
/RaysStrokeCode
{
ThisName (Julian) eq {0.75 setgray stroke}
{
0.36 setlinewidth
WithinPage0 WithinPage1 eq
{
GlassesOnSheets SheetNum get length dup dup 4 div CoprimeNear
WithinPage0 mul 1 index mod exch div 1 1 sethsbcolor stroke
}
{
strokepath clipsave clip
<<
/Function
<<
/DataSource
GlassesOnSheets SheetNum get length dup dup 4 div CoprimeNear
WithinPage0 mul 1 index mod exch div 1 1 gsave sethsbcolor
currentrgbcolor grestore
GlassesOnSheets SheetNum get length dup dup 4 div CoprimeNear
WithinPage1 mul 1 index mod exch div 1 1 gsave sethsbcolor
currentrgbcolor grestore
(123456) % 6 numbers, one byte each; can re-use string so will
5 -1 0 {exch dup 4 2 roll exch 255 mul 0.5 add floor cvi put}
for
/BitsPerSample 8
/FunctionType 0 /Domain [0 1] /Range [0 1 0 1 0 1] /
Order 1 /Size [2] /N 1
>>
/Coords [ X0 Y0 X1 Y1 ]
/ShadingType 2 /ColorSpace /DeviceRGB /Extend [true dup]
>>
shfill cliprestore newpath
} ifelse % WithinPage0 WithinPage1 eq
} ifelse % ThisName ...
} def % /RaysStrokeCode
/RaysStrokeCode
{
ThisName (Julian) eq {0.75 setgray stroke}
{
0.36 setlinewidth
WithinPage0 WithinPage1 eq
{
RaysAngle0 90 add RaysAngleOffset sub 1 mul 360 div {dup 1 ge {1
sub} {exit} ifelse} loop 1 0.8 sethsbcolor stroke
}
{
strokepath clipsave clip
% Help received at groups.google.com/group/comp.lang.postscript/
browse_thread/thread/888d4167a7eaadb2
<<
/Function
<<
/DataSource
RaysAngle0 90 add RaysAngleOffset sub 1 mul 360 div {dup 1 ge {1
sub} {exit} ifelse} loop 1 0.8 gsave sethsbcolor currentrgbcolor
grestore
RaysAngle1 90 add RaysAngleOffset sub 1 mul 360 div {dup 1 ge {1
sub} {exit} ifelse} loop 1 0.8 gsave sethsbcolor currentrgbcolor
You can easily use a PostScript function as the basis for the data in a
function dictionary.
That is one of PostScript's strongest features.
Exactly what are you trying to do?
--
Many thanks,
Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: d...@tinaja.com
Please visit my GURU's LAIR web site at http://www.tinaja.com