Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trying to draw a spiral

9 views
Skip to first unread message

Gerald Gutierrez

unread,
May 2, 1999, 3:00:00 AM5/2/99
to

Hi all.

I'm trying to figure out how to create a spiral path so that I can stroke it or
lay text on it.

As I understand, Postscript gives me the arc* and curve* operators, the former
of which draws circular arcs and the latter, Bezier curves. I suppose this
means I must use the curve operators.

If this is the case, how do I go about figuring out the control points and the
number of curves I need?

Thanks.


Himanshu Gohel

unread,
May 3, 1999, 3:00:00 AM5/3/99
to
In article <925666977....@news.intergate.bc.ca>, Gerald Gutierrez <gut...@intergate.bc.ca> writes:

>I'm trying to figure out how to create a spiral path so that I can stroke
>it or lay text on it.

For the life of me I can't remember which book I've seen that example
in, but I have...if you have "PostScript by Example," the blue book,
or the PS Reference Manual, check them...I've seen it.

>As I understand, Postscript gives me the arc* and curve* operators, the former
>of which draws circular arcs and the latter, Bezier curves. I suppose this
>means I must use the curve operators.
>If this is the case, how do I go about figuring out the control points and the
>number of curves I need?

You got me thinking...it's not necessary to use Bezier curves. Like you
said, if you do, you have to figure out control points. I just drew
a sprial on a piece of paper by drawing:

1. concentric circles, 4mm, 3mm, 2mm, 1mm radii.
2. drawing the inner cirles of 3mm, 2mm and 1mm at an offset of 1mm
from the original center
3. tracing along the "appropriate" line to form a spiral. You will
know what is "appropriate" when you do it on paper. I'm not sure
of the mathematical definition of a spiral, but this look OK to me.

Hmmm...looks like the are simply half circles! At each level just
reduce the radius by your step size...the PS arc command should work
just fine!

--
Himanshu Gohel, mailto:go...@csee.usf.eduXXX <- remove XXX to reply
<A HREF="http://www.csee.usf.edu/~gohel/"></A>
Geometric Modeling & Graphics Research Group,U of South Florida, Tampa, FL. USA

PostScript FAQ:
http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.postscript.html

vepxist...@my-dejanews.com

unread,
May 4, 1999, 3:00:00 AM5/4/99
to
Use PostScript itself (I have code for this *somewhere*) -- or an application
such as Mathematica, MatLab, or Maple -- to create a spiral from an equation.

Then import that file into Illustrator (or whatever) as a template and trace
it.

SFAIK, no illustration app supports spirals in any other way.

Fred


In article <925666977....@news.intergate.bc.ca>,
Gerald Gutierrez <gut...@intergate.bc.ca> wrote:
>
> Hi all.


>
> I'm trying to figure out how to create a spiral path so that I can stroke it
or
> lay text on it.
>

> As I understand, Postscript gives me the arc* and curve* operators, the former
> of which draws circular arcs and the latter, Bezier curves. I suppose this
> means I must use the curve operators.
>
> If this is the case, how do I go about figuring out the control points and the
> number of curves I need?
>

> Thanks.
>
>


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

George Spowart

unread,
May 4, 1999, 3:00:00 AM5/4/99
to
In article <7gnal0$ip9$1...@nnrp1.dejanews.com>, vepxistqaosani@my-
dejanews.com writes
Hello there

I know this wasn't the original question but for the sake of accuracy
may I point out that CorelDraw v.7 (and presumably v.8) has the facility
to draw both symmetrical (number of revolutions) and logarithmic (number
of revolutions) and logarithmic (number of revolutions and expansion)
spirals.

BTW the following code makes a stab at symmetrical spirals.

%!
/inch {72 mul} def
/xorigin 4 inch def
/yorigin 5 inch def
/startradius 1 inch def
/startangle 90 def
/gap 1 inch def
%/turns 6 def % may be preferred to next 2 lines
/finalradius 2.8 inch def
/turns finalradius startradius div def
/angleincrement 1 def
/xincrement gap 360 div def
/linewidth 0.125 inch def
/hand (right) def % or change to /hand (left) def
/dospiral {
gsave
hand (left) eq {1} {-1} ifelse 1 scale % set
'handedness'
startangle rotate
startradius 0 moveto
turns 360 mul cvi{
/startradius startradius xincrement add def
startradius startradius angleincrement sin mul lineto
angleincrement rotate
} repeat
0 1 0 setrgbcolor % colour can be changed
linewidth setlinewidth stroke
grestore
} def
xorigin yorigin translate dospiral
showpage

regards

George

George Spowart
e-mail : geo...@h2opolo.demon.co.uk

George Jefferson

unread,
May 4, 1999, 3:00:00 AM5/4/99
to
:>> I'm trying to figure out how to create a spiral path so that I can

:stroke it
:>or
:>> lay text on it.
^^^^^^^^^^^^^^^^

now what about part b ? <grin>

--
george jefferson : geo...@sol1.lrsm.upenn.edu
to reply simply press "r"
-- I hate editing addresses more than I hate the spam!


George Spowart

unread,
May 5, 1999, 3:00:00 AM5/5/99
to
In article <7gnghq$vcb$1...@netnews.upenn.edu>, George Jefferson
<geo...@sol1.lrsm.upenn.edu> writes

>:>> I'm trying to figure out how to create a spiral path so that I can
>:stroke it
>:>or
>:>> lay text on it.
> ^^^^^^^^^^^^^^^^
>
>now what about part b ? <grin>
>
Sorry, I would use CorelDraw for that too but the following just uses
the old Cookbook code along with my quick spiral - not a complete
solution and I'm sure there are neater, better ways of drawing spirals

%!
% Cookbook Example Program from First Printing, Revised 7 Jan 1985
% Program: Placing Text Along an Arbitrary Path Number: 17
%-----------------------------------------------------------------------
------
%
/pathtextdict 26 dict def % Local storage for the
procedure
% ``pathtext.''

/pathtext % ``pathtext'' will place a
string
{ pathtextdict begin % of text along any path. It
takes
/offset exch def % a string and starting
offset
/str exch def % distance from the
beginning of
% the path as its arguments.
Note
% that ``pathtext'' assumes
that a
% path has already been
defined
% and after it places the
text
% along the path, it clears
the
% current path like the
``stroke''
% and ``fill'' operators; it
also
% assumes that a font has
been
% set. ``pathtext'' begins
placing
% the characters along the
current
% path, starting at the
offset
% distance and continuing
until
% either the path length is
% exhausted or the entire
string
% has been printed,
whichever
% occurs first. The results
will
% be more effective when a
small
% point size font is used
with
% sharp curves in the path.

/pathdist 0 def % Initialize the distance we
have
% travelled along the path.
/setdist offset def % Initialize the distance we
have
% covered by setting
characters.
/charcount 0 def % Initialize the character
count.
gsave
flattenpath % Reduce the path to a
series of
% straight line segments.
The
% characters will be placed
along
% the line segments in the
% ``linetoproc.''
{movetoproc} {linetoproc} % The basic strategy is to
process
{curvetoproc} {closepathproc} % the segments of the path,
pathforall % keeping a running total of
the
% distance we have travelled
so
% far (pathdist). We also
keep
% track of the distance
taken up
% by the characters that
have been
% set so far (setdist). When
the
% distance we have travelled
along
% the path is greater than
the
% distance taken up by the
set
% characters, we are ready
to set
% the next character (if
there are
% any left to be set). This
% process continues until we
have
% exhausted the full length
of the
% path.
grestore
newpath % Clear the current path.
end
} def

pathtextdict begin
/movetoproc % ``movetoproc'' is executed
when
{ /newy exch def /newx exch def % a moveto component has
been
% encountered in the
pathforall
% operation.
/firstx newx def /firsty newy def % Remember the ``first
point'' in
% the path so that when we
get a
% ``closepath'' component we
can
% properly handle the text.
/ovr 0 def
newx newy transform
/cpy exch def /cpx exch def % Explicitly keep track of
the
% current position in device
% space.
} def

/linetoproc % ``linetoproc'' is executed
when
% a lineto component has
been
% encountered in the
pathforall
% operation.
{ /oldx newx def /oldy newy def % Update the old point.
/newy exch def /newx exch def % Get the new point.
/dx newx oldx sub def
/dy newy oldy sub def
/dist dx dup mul dy dup mul add % Calculate the distance
between
% the old and the new point.
sqrt def
/dsx dx dist div ovr mul def % dsx and dsy are used to
update
/dsy dy dist div ovr mul def % the current position to be
just
% beyond the width of the
previous
% character.
oldx dsx add oldy dsy add transform
/cpy exch def /cpx exch def % Update the current
position.
/pathdist pathdist dist add def % Increment the distance we
have
% travelled along the path.
{ setdist pathdist le % Keep setting characters
along
% this path segment until we
have
% exhausted its length.
{ charcount str length lt % As long as there are still
{setchar} {exit} ifelse } % characters left in the
string,
% set them.
{ /ovr setdist pathdist sub def % Keep track of how much we
have
exit } % overshot the path segment
by
ifelse % setting the previous
character.
% This enables us to
position the
% origin of the following
% characters properly on the
path.
} loop
} def

/curvetoproc % ``curvetoproc'' is
executed when
{ (ERROR: No curveto's after flattenpath!)% a curveto component has
been
print % encountered in the
pathforall
} def % operation. It prints an
error
% message since there
shouldn't be
% any curveto's in a path
after
% the flattenpath operator
has
% been executed.

/closepathproc % ``closepathproc'' is
executed
{ firstx firsty linetoproc % when a closepath component
has
firstx firsty movetoproc % been encountered in the
} def % pathforall operation. It
% simulates the action of
the
% operator ``closepath'' by
% executing ``linetoproc''
with
% the coordinates of the
most
% recent ``moveto'' and then
% executing ``movetoproc''
to the
% same point.

/setchar % ``setchar'' sets the next
{ /char str charcount 1 getinterval def % character in the string
along
% the path and then updates
the
% amount of path we have
% exhausted.
/charcount charcount 1 add def % Increment the character
count.
/charwidth char stringwidth pop def % Find the width of the
character.
charwidth =
gsave
cpx cpy itransform translate % Translate to the current
% position in user space.
dy dx atan rotate % Rotate the x-axis to
coincide
% with the current segment.
charwidth 2 div neg 0 moveto char show
charwidth 2 div 0 rmoveto
currentpoint transform
/cpy exch def /cpx exch def % Update the current
position
grestore % before we restore
ourselves to
% the untransformed state.
/setdist setdist charwidth add def % Increment the distance we
have
} def % covered by setting
characters.
end
/Helvetica-Bold findfont 18 scalefont setfont
newpath % Define the path along
which we
% wish to place the text.
% GS SPIRAL FROM HERE


/inch {72 mul} def
/xorigin 4 inch def
/yorigin 5 inch def
/startradius 1 inch def
/startangle 90 def
/gap 1 inch def
%/turns 6 def % may be preferred to next 2 lines
/finalradius 2.8 inch def
/turns finalradius startradius div def
/angleincrement 1 def
/xincrement gap 360 div def
/linewidth 0.125 inch def

/dospiral {


startangle rotate
startradius 0 moveto
turns 360 mul cvi{
/startradius startradius xincrement add def
startradius startradius angleincrement sin mul lineto
angleincrement rotate
} repeat

} def
xorigin yorigin translate

% FINISH WITH CALL TO COOKBOOK CODE
dospiral (
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG AND SO ON AND SO ON AD
INFINITUM - THIS IS JUST A QUICK LASH-UP AND THE SPIRAL MAY NOT BE THE
TYPE REQUIRED BUT I HOPE IT GIVES A START POINT - LETTER "I" KERNING
PRETTY POOR
) 0 pathtext
showpage

George Spowart
e-mail : geo...@h2opolo.demon.co.uk

M. Schulter

unread,
May 6, 1999, 3:00:00 AM5/6/99
to
George Jefferson <geo...@sol1.lrsm.upenn.edu> wrote:
: :>> I'm trying to figure out how to create a spiral path so that I can

: :stroke it
: :>or
: :>> lay text on it.
: ^^^^^^^^^^^^^^^^

: now what about part b ? <grin>

Hello, there, and back around the early 1990's I developed a variant on
the "circletext" routine in the Adobe Blue Book which sets text in spirals
rather than the usual circles. This routine supports various special
effects using _charpath_ rather than _show_, and also has optional pair
kerning as well as a "setspiralacceleration" factor to adjust the shape of
the spiral.

This code is part of a 180K prologue which I'd be glad to send via e-mail
in ASCII PS or PKZIP format (I should be able to produce GZIP as well),
along with some sample script files using this routine to create spiral
text.

As another person pointed out, it would also be possible to use Adobe's
companion pathtext routine from the Blue Book.

If people are interested, I might be able to post the "spiraltext" routine
as standalone code after untangling dependencies on things elsewhere in
the prologue. Maybe this file serves as proof that PostScript is not
necessarily the most "structured" language <grin>.

Most respectfully,

Margo Schulter
msch...@value.net


George Spowart

unread,
May 6, 1999, 3:00:00 AM5/6/99
to
In article <7gr10a$9os$2...@vnetnews.value.net>, M. Schulter
<msch...@value.net> writes
Hello again

May I point out that Margo Schulter was kind enough to send me her
prologue some time ago and I can confirm that her spiral routines are
vastly superior to my quick post. I hadn't "disentangled" them either
and went for a "rough and ready" response. Nevertheless I should have
mentioned Margo's routines and I apologise to her.

Regards

M. Schulter

unread,
May 6, 1999, 3:00:00 AM5/6/99
to
George Spowart <geo...@h2opolo.demon.co.uk> wrote:

: May I point out that Margo Schulter was kind enough to send me her


: prologue some time ago and I can confirm that her spiral routines are
: vastly superior to my quick post. I hadn't "disentangled" them either
: and went for a "rough and ready" response. Nevertheless I should have
: mentioned Margo's routines and I apologise to her.

Hello, there, and I just want to say that while I'm naturally delighted by
these kind words, I really feel that no apology is necessary. You
presented a solution which could easily be posted here, and also which
shows a routine which be used to set text along any kind of shape the user
may invent. That's an important technique in itself.

Please let me add that if I apologized for each time that I post a
"solution" here without explicitly acknowledging alternatives which might
just be at least as attractive to the user -- both the ones of which I'm
aware, and the ones of which I may _not_ be aware -- I would need to do a
lot of apologizing for a substantial percentage of my posts.

You do a fine service for this newsgroup by causing me and others to
reflect on this fact: our posts are necessarily selective and incomplete.
It seems to me that the best solution is to have lots of helpful people
sharing whatever solutions occur to them at a given moment, trusting that
the process of dialogue will reveal something of the range of choices.

Most appreciatively,

Margo Schulter
msch...@value.net


Eugene H. Laird

unread,
May 12, 1999, 3:00:00 AM5/12/99
to
Here's something I saved from this newsgroup many moons aga.

%!
% Copyright (C) 1987 by Pipeline Associates, Inc.
% Permission is granted to copy and distribute this file if
% this message is left intact and nothing is charged for it.
% spiral text

/pi 3.1415923 def
/str1 ( ) def

/spiral {
gsave
/rad exch def % radius
/ptsize exch def % point size
/str exch def % string to show

% use xrad for width computations...
% fudged by adding 1/4 point size to
% real radius; done to tighten up
% intercharacter spacing
/xrad rad ptsize 4 div add def

% start spiral at lhs of page
180 rotate

str {
% ASCII value of char
/charcode exch def

% convert to string
str1 0 charcode put

% show string
str1 angshow

% comment out next line to produce circular text
.995 .995 scale
} forall
grestore
} def

/angshow {
/char exch def

% angular "width" of character
/angle char stringang def

gsave

% rotate through 1/2 char's width
angle 2 div neg rotate

% show character at end of radius
rad 0 translate

% char is perpendicular to radius
-90 rotate

% center character and show
char stringwidth pop 2 div neg 0 moveto
char show
grestore

% rotate through char's "width" to set
% up next char
angle neg rotate
} def

/stringang {
stringwidth pop % x width of string
2 xrad mul pi mul % diameter of circle
div 360 mul % convert to degrees
} def

120 120 translate
/Times-Roman findfont 15 scalefont setfont

% comment out the next line to get a normal spiral
1 .3 scale

(The PostScript Language Journal
The PostScript Language Journal
The PostScript Language Journal
The PostScript Language Journal
The PostScript Language Journal
The PostScript Language Journal)
15 60 spiral

showpage


Cordially,
E. Laird

Gerald Gutierrez wrote:

>
> Hi all.


>
> I'm trying to figure out how to create a spiral path so that I can stroke it or
> lay text on it.
>

jdaw1

unread,
Aug 8, 2022, 6:25:11 PM8/8/22
to
0 new messages