Path: csiph.com!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Don Lancaster Newsgroups: comp.lang.postscript Subject: Re: merging colors.. Date: Tue, 02 Apr 2013 17:03:07 -0700 Lines: 355 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net Usgbcx7HcouvRiCeQhLO+g4Btc+uqvvQD+DbxqErUrF/j+WyA2 Cancel-Lock: sha1:wmKmFOmLeYKD3uSOoGxlFaJTF9o= User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 In-Reply-To: Xref: csiph.com comp.lang.postscript:1366 On 4/1/2013 2:04 AM, gernot.hoffmann@hs-emden-leer.de wrote: > Am Montag, 1. April 2013 04:18:49 UTC+2 schrieb Robert Baer: >> 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 > > Some examples: > > http://docs-hoffmann.de/ciegraph17052004.pdf > > %!PS-Adobe-3.0 EPSF-3.0 > %%BoundingBox: 0 0 567 567 > %%Creator: Gernot Hoffmann > %%Title: CMY-Circles > %%CreationDate: June 07 / 2006 > > /mm {2.834646 mul} def > > /sc 80 mm def > /x0 100 mm def > /y0 100 mm def > > /BBox > { 0 0 567 567 rectstroke > } def > > % BBox > > /E 0.5 def > /R 0.7 def > > /ac 180 def > /am 300 def > /ay 60 def > > /xc ac cos E mul def > /yc ac sin E mul def > /xm am cos E mul def > /ym am sin E mul def > > /xy ay cos E mul def > /yy ay sin E mul def > > x0 y0 translate > sc sc scale > > gsave > 1 0 0 0 setcmykcolor > xc yc R 0 360 arc fill > > 0 1 0 0 setcmykcolor > xm ym R 0 360 arc fill > > 0 0 1 0 setcmykcolor > xy yy R 0 360 arc fill > > grestore > gsave > newpath xc yc R 0 360 arc clip > newpath xm ym R 0 360 arc clip > > 1 1 0 0 setcmykcolor > xc yc R 0 360 arc fill > > grestore > gsave > newpath xm ym R 0 360 arc clip > newpath xy yy R 0 360 arc clip > > 0 1 1 0 setcmykcolor > xm ym R 0 360 arc fill > > grestore > gsave > newpath xy yy R 0 360 arc clip > newpath xc yc R 0 360 arc clip > > 1 0 1 0 setcmykcolor > xy yy R 0 360 arc fill > > grestore > gsave > newpath xc yc R 0 360 arc clip > newpath xm ym R 0 360 arc clip > newpath xy yy R 0 360 arc clip > > 1 1 1 0 setcmykcolor > xc yc R 0 360 arc fill > > showpage > > --------------------- > > %!PS-Adobe-3.0 EPSF-3.0 > %%BoundingBox: 0 0 567 567 > %%Creator: Gernot Hoffmann > %%Title: RGB-Circles > %%CreationDate: June 07 / 2006 > > /mm {2.834646 mul} def > > /sc 80 mm def > /x0 100 mm def > /y0 100 mm def /BBox > { 0 0 567 567 rectstroke > } def > > % BBox > > /E 0.5 def > /R 0.7 def > > /ar 0 def > /ag 120 def > /ab 240 def > > /xr ar cos E mul def > /yr ar sin E mul def > /xg ag cos E mul def > /yg ag sin E mul def > > /xb ab cos E mul def > /yb ab sin E mul def > > x0 y0 translate > sc sc scale > > gsave > 1 0 0 setrgbcolor > xr yr R 0 360 arc fill > > 0 1 0 setrgbcolor > xg yg R 0 360 arc fill > > 0 0 1 setrgbcolor > xb yb R 0 360 arc fill > > grestore > gsave > newpath xr yr R 0 360 arc clip > newpath xg yg R 0 360 arc clip > > 1 1 0 setrgbcolor > xr yr R 0 360 arc fill > > grestore > gsave > newpath xg yg R 0 360 arc clip > newpath xb yb R 0 360 arc clip > > 0 1 1 setrgbcolor > xg yg R 0 360 arc fill > > grestore > gsave > newpath xb yb R 0 360 arc clip > newpath xr yr R 0 360 arc clip > > 1 0 1 setrgbcolor > xb yb R 0 360 arc fill > > grestore > gsave > newpath xr yr R 0 360 arc clip > newpath xg yg R 0 360 arc clip > newpath xb yb R 0 360 arc clip > > 1 1 1 setrgbcolor > xr yr R 0 360 arc fill > > showpage > < http://www.tinaja.com/glib/pstrans2.pdf > , of course. Otherwise, you have to work with the HSB color space and make sure you do not go the wrong way around the circle. As in < http://www.tinaja.com/glib/postproc.pdf > -- 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: don@tinaja.com Please visit my GURU's LAIR web site at http://www.tinaja.com