Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #778
| From | JohnF <john@please.see.sig.for.email.com> |
|---|---|
| Newsgroups | comp.lang.postscript |
| Subject | Re: setrgbcolor with lineto/curveto |
| Date | 2012-07-04 03:07 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <jt0c0p$65q$1@reader1.panix.com> (permalink) |
| References | <jra5b7$mqu$1@reader1.panix.com> <2012063010205688771-john@acumentrainingcom> |
John Deubert <john@acumentraining.com> wrote:
> Just for the record, here's a smooth shading (partial) solution. It's
> smaller and cleaner (I think), but does require a Level 3 interpreter.
> Also, this produces the desired results only if you are stroking a
> single line segment or not-very-curvy bezier; it won't fail with a more
> complex path, but will probably not give the results you want. A final
> solution would require some surgery on the code.
Thanks for the solution below, John. Who'd have thought there'd be
an www.acumentraining.com with an www.acumentraining.com/acumenjournal.html
for postscript (and pdf) training classes (and consulting)?
I've already incorporated Prof. Hoffmann's previous solution into
the C program generating the ps designs, and some sample output
is at http://www.forkosh.com/decorative1.ps with those procedures
at the top. Note that I also took the opportunity to use Prof. Hoffmann's
"s=s+ds, 0<=s<=1" loop to vary the linewidth from one endpoint to the other,
so lines can optionally (user's choice) look like (elongated) wedges.
But I'm definitely saving and will be studying your code, too (who,
exactly, is Bob, by the way?). Looks like it will require a bit more
side-by-side reading along with the plrm or bluebook, though I'm
already seeing your additional techniques for handling arguments
beyond /arg exch def. And, while I'd (very) briefly read about arrays and
dictionaries, I hadn't seen any examples (beyond those in the bluebook)
I was actually interested in. So it's already very instructive.
Thanks a lot.
> % ============== cut here ===========
> /ShadingDict << % This dict defines the gradient.
> /ShadingType 2 % We'll use a linear gradient...
> /ColorSpace [ /DeviceRGB ] % ...in RGB
> /Coords [ 200 200 400 400 ] % These are the same as line seg endpts
> /Domain [ 0 1 ] % Internal parameter
> /Function << % This defines how the color should...
> /FunctionType 2 % ...vary across the line
> /Domain [ 0 1 ]
> /Range [ 0 1 0 1 0 1 ] % R, G, & B each can vary from 0 to 1
> /C0 [ 1 0 0 ] % Start Color
> /C1 [ 0 1 0 ] % End Color
> /N 1 % Varies linearly
> >>
>>> def
>
> 3 setlinewidth % Construct our path
> 200 200 moveto 400 400 lineto
> strokepath clip % Turn it into a clipping region
> ShadingDict shfill % Fill it with out gradient; Bob's your uncle!
>
> showpage
> % ============== cut here ===========
>
>
> As long as I'm messing about with this (and what do *you* do on a
> Saturday morning?) here's the same technique turned into a procedure
> named strokegradientline:
>
> % ============== cut here ===========
> /ShadingDict << % Same ShadingDict as earlier.
> /ShadingType 2
> /ColorSpace [ /DeviceRGB ]
> /Coords [ 200 200 400 400 ]
> /Domain [ 0 1 ]
> /Function <<
> /FunctionType 2
> /Domain [ 0 1 ]
> /Range [ 0 1 0 1 0 1 ]
> /C0 [ 1 0 0 ]
> /C1 [ 0 1 0 ]
> /N 1
> >>
>>> def
>
>
> /strokegradientline % [ r0 g0 b0 ] [ r1 g1 b1 ] x0 y0 x1 y1 => ---
> {
> gsave
> 4 copy moveto lineto % first let's the line
> strokepath clip % and turn it into a clipping path
> ShadingDict begin % Go get our Shading dictionary
> 4 array astore % Put the xy's into an array
> /Coords exch def % And use it for the Coords entry
> Function begin % Get the function dictionary
> /C1 exch def % Put our colors into it as C0 and C1
> /C2 exch def
> end end % Clean up the dict stack
> ShadingDict shfill % And shfill it.
> grestore % Restore our clipping path
> } bind def
>
> % And now try this puppy out
> 3 setlinewidth
> [ 1 0 0 ][ 0 0 1 ] 200 200 400 400 strokegradientline
> [ 0 1 1 ][ 1 1 0 ] 300 200 500 400 strokegradientline
>
> showpage
> % ============== cut here ===========
>
> Again, this isn't a final solution to the problem of an arbitrary path,
> but I thought a
> Smooth Shading example was called for.
>
> If you're curious about Smooth Shading, I wrote an article on the
> subject for my Acumen Journal ages ago (let's look that up...ah.
> November 2000; issue 1, actually). You can get it free for the
> downloading at www.acumentraining.com/acumenjournal.html.
--
John Forkosh ( mailto: j@f.com where j=john and f=forkosh )
Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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