Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!postnews.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!panix!not-for-mail From: JohnF Newsgroups: comp.lang.postscript Subject: Re: setrgbcolor with lineto/curveto Date: Tue, 19 Jun 2012 07:00:42 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 104 Message-ID: References: NNTP-Posting-Host: panix3.panix.com X-Trace: reader1.panix.com 1340089242 22712 166.84.1.3 (19 Jun 2012 07:00:42 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 19 Jun 2012 07:00:42 +0000 (UTC) User-Agent: tin/2.0.0-20110823 ("Ardenistiel") (UNIX) (NetBSD/5.1.2 (i386)) Xref: csiph.com comp.lang.postscript:752 gernot.hoffmann@hs-emden-leer.de wrote: > Below a simple solution, using basic Bezier definitions. > > http://www.fho-emden.de/~hoffmann/bezier18122002.pdf > page 2 > > Best regards --Gernot Hoffmann Thanks a lot for your help again, Prof. Hoffmann (I recall your previous help in comp.graphics.algorithms, which was regarding the same little decorative program www.forkosh.com/lineart.html that I'm further modifying now). I took your solution and simplified it a bit as illustrated below, replacing bezier curves with straight lines so I could follow your postscript ideas more easily. After that worked, I abstracted your 100-step loop into a function /Coline so that the program can draw many lines, % X0,Y0=start point, X1,Y1=end point /X0 1.0 def /Y0 0.0 def /X1 0.0 def /Y1 1.0 def Coline /X0 0.0 def /Y0 0.0 def /X1 1.0 def /Y1 1.0 def Coline So the example below just draws a big X. Ultimately, the program will first generate your "stub" at top, followed by many, many, many X0,Y0,X1,Y1 lines. Then I'll re-introduce your original /Func (and /Coeff and control points) for bezier curveto's. Thanks again, John (sig and email at bottom) ----- %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 340 340 %%Creator: Gernot Hoffmann %%Title: Color interpolation along line %%CreationDate: June 15 / 2012 % Bezier Reference: % http://www.fho-emden.de/~hoffmann/bezier18122002.pdf % page 2 % RGB0=Start color, RGB1=End color /R0 0.0 def /G0 0.5 def /B0 0.0 def /R1 1.0 def /G1 0.5 def /B1 0.0 def % number of steps /N 100 def % e.g. 100 subdivisions /dt 1 N div def /Ipol % color interpolation R = (R1-R0)*t + R0, similarly for G,B {/r R1 R0 sub t mul R0 add def /g G1 G0 sub t mul G0 add def /b B1 B0 sub t mul B0 add def r g b setrgbcolor } def /Func % straight line x = (X1-X0)*t + X0, similarly for y {/x X1 X0 sub t mul X0 add def /y Y1 Y0 sub t mul Y0 add def } def /Coline % color line {/t 0 def Func N { Ipol x y moveto /t t dt add def Func x y lineto stroke } repeat } def /mm {2.834646 mul} def 100 mm 100 mm scale 0.1 0.1 translate % black axis lines 0.001 setlinewidth 0 0 moveto 1 0 lineto stroke 0 0 moveto 0 1 lineto stroke % color lines 0.01 setlinewidth % X0,Y0=start point, X1,Y1=end point /X0 1.0 def /Y0 0.0 def /X1 0.0 def /Y1 1.0 def Coline % X0,Y0=start point, X1,Y1=end point /X0 0.0 def /Y0 0.0 def /X1 1.0 def /Y1 1.0 def Coline showpage ----- -- John Forkosh ( mailto: j@f.com where j=john and f=forkosh )