Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #752

Re: setrgbcolor with lineto/curveto

From JohnF <john@please.see.sig.for.email.com>
Newsgroups comp.lang.postscript
Subject Re: setrgbcolor with lineto/curveto
Date 2012-06-19 07:00 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <jrp82q$m5o$1@reader1.panix.com> (permalink)
References <jra5b7$mqu$1@reader1.panix.com> <e541e1bb-8ccd-4742-b96f-ab48ee60c0a7@googlegroups.com>

Show all headers | View raw


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 )

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-13 13:41 +0000
  Re: setrgbcolor with lineto/curveto Helge Blischke <h.blischke@acm.org> - 2012-06-13 16:16 +0200
    Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-13 16:04 +0000
    Re: setrgbcolor with lineto/curveto Odysseus <odysseus1479-at@yahoo-dot.ca> - 2012-06-13 20:20 -0600
      Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-14 04:05 +0000
      Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-16 14:45 -0700
  Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-13 16:20 -0700
    Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-13 17:16 -0700
      Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-13 17:36 -0700
        Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-14 04:11 +0000
          Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-14 09:05 -0700
  Re: setrgbcolor with lineto/curveto gernot.hoffmann@hs-emden-leer.de - 2012-06-16 11:00 -0700
  Re: setrgbcolor with lineto/curveto gernot.hoffmann@hs-emden-leer.de - 2012-06-16 10:55 -0700
    Re: setrgbcolor with lineto/curveto gernot.hoffmann@hs-emden-leer.de - 2012-06-16 11:23 -0700
    Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-19 07:00 +0000
      Re: setrgbcolor with lineto/curveto gernot.hoffmann@hs-emden-leer.de - 2012-06-19 00:34 -0700
        Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-19 08:12 +0000
  Re: setrgbcolor with lineto/curveto John Deubert <john@acumentraining.com> - 2012-06-30 10:20 -0700
    Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-07-04 03:07 +0000
      Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-07-05 16:24 -0700
        Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-07-06 14:23 +0000
          Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-07-11 01:57 +0000
        Re: setrgbcolor with lineto/curveto tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-07-11 01:08 -0400
          Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-07-12 03:12 -0700
            Re: setrgbcolor with lineto/curveto tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-07-12 22:20 -0400

csiph-web