This is my first "fancy" program, three color-shaded circles.
It would be nice to have the colors appropriately combine/add in the
overlap regions.
Is there a nice way to do that?
%! %
three.ps
/inch {72 mul} def % 72 pixels to the inch
/N 500 def % steps
/red 1 def
/green {1 3 div} def
/blue {2 3 div} def
/size {dup inch exch inch scale} def
/circle
{
newpath
exch % order: hue sat on top
0 0 moveto % (circlestack) stack pop % ? where does it go?
1 sethsbcolor % hue sat 1
0 0 1 -270 90 arc % includes a straight line to the initial
point of the arc
% x y r ang1 ang2 % from, to angles
closepath % and a curved section to the end of the arc.
pop
} def
gsave
267 400 translate % middle, landscape
1 1 N % Set up the for operator to iterate
{
gsave % Enclose the ‘‘circle’’ operation in a
gsave - grestore
% radius must shrink as sat grows for proper shading..
dup N exch sub N div dup 3 mul size
1 exch sub
red circle
gsave fill grestore % Save the circle path for use after the
fill.
grestore % Get out of the coordinate system left
by circle.
} for % Close the procedure body and execute
the for operator.
grestore
gsave
400 200 translate % middle, landscape
1 1 N % Set up the for operator to iterate
{
gsave % Enclose the ‘‘circle’’ operation in a
gsave - grestore
% radius must shrink as sat grows for proper shading..
dup N exch sub N div dup 3 mul size
1 exch sub
green circle
gsave fill grestore % Save the circle path for use after the
fill.
grestore % Get out of the coordinate system left
by circle.
} for % Close the procedure body and execute
the for operator.
grestore
gsave
533 400 translate % middle, landscape
1 1 N % Set up the for operator to iterate
{
gsave % Enclose the ‘‘circle’’ operation in a
gsave - grestore
% radius must shrink as sat grows for proper shading..
dup N exch sub N div dup 3 mul size
1 exch sub
blue circle
gsave fill grestore % Save the circle path for use after the
fill.
grestore % Get out of the coordinate system left
by circle.
} for % Close the procedure body and execute
the for operator.
grestore
gsave
/Helvetica findfont
24 scalefont setfont
320 580 moveto
( Linear gradient) show
grestore
showpage