[comp.windows.news] How do you get rid of the current point

sjs@spectral.ctt.bellcore.com (Stan Switzer) (08/05/89)

In PostScript, how do you nuke the current point, making no other
changes to the graphics state?

The situation is this: I have part of a path already constructed and
I'd like to add an "arc" segment without the line leading from the
current point to the arc.

In NeWS, "closepath" (which I happened to need anyway) gets rid of the
current point, but on a LaserWriter the current point seems to be
unaffected.

Any suggestions?

Stan Switzer  sjs@ctt.bellcore.com

ciemo@bananapc.wpd.sgi.com (Dave Ciemiewicz) (08/05/89)

In article <17344@bellcore.bellcore.com>, sjs@spectral.ctt.bellcore.com (Stan Switzer) writes:
> In PostScript, how do you nuke the current point, making no other
> changes to the graphics state?
> 
> The situation is this: I have part of a path already constructed and
> I'd like to add an "arc" segment without the line leading from the
> current point to the arc.
> 
> In NeWS, "closepath" (which I happened to need anyway) gets rid of the
> current point, but on a LaserWriter the current point seems to be
> unaffected.
> 
> Any suggestions?
> 
> Stan Switzer  sjs@ctt.bellcore.com

This seems so obvious I wonder if I'm missing something in the discussion.
Why not use the "moveto" operator?  The red books says:

	[moveto] starts a new subpath of the currect path.  moveto sets
	the current point ... without adding any line segments to the
	current path.

--
-------------------------------------------------------------------------------
			Cosmo Ciemo, Silicon Valley Dude

I was traipsing through the fields of my mind when I stepped in something that
smelled rather ripe.
-------------------------------------------------------------------------------

ciemo@bananapc.wpd.sgi.com (Dave Ciemiewicz) (08/05/89)

In article <39596@sgi.SGI.COM>, ciemo@bananapc.wpd.sgi.com (Dave Ciemiewicz) writes:
> In article <17344@bellcore.bellcore.com>, sjs@spectral.ctt.bellcore.com (Stan Switzer) writes:
> > In PostScript, how do you nuke the current point, making no other
> > changes to the graphics state?
> > 
> > The situation is this: I have part of a path already constructed and
> > I'd like to add an "arc" segment without the line leading from the
> > current point to the arc.
> > 
> > In NeWS, "closepath" (which I happened to need anyway) gets rid of the
> > current point, but on a LaserWriter the current point seems to be
> > unaffected.
> > 
> > Any suggestions?
> > 
> > Stan Switzer  sjs@ctt.bellcore.com
> 
> This seems so obvious I wonder if I'm missing something in the discussion.
> Why not use the "moveto" operator?  The red books says:
> 
> 	[moveto] starts a new subpath of the currect path.  moveto sets
> 	the current point ... without adding any line segments to the
> 	current path.
> 

Thinking about it some more, it seems you want a single path, constructed
of multiple, discontinuous subpaths.  One of these subpaths is to be an
arc.  In the past, I've used "moveto" to position the currentpoint to the
start of the arc to eliminate the leading line.

The other option might be to have multiple paths and just issue a "newpath"
before the "arc" operator.


--
-------------------------------------------------------------------------------
			Cosmo Ciemo, Silicon Valley Dude

I was traipsing through the fields of my mind when I stepped in something that
smelled rather ripe.
-------------------------------------------------------------------------------

sjs@spectral.ctt.bellcore.com (Stan Switzer) (08/07/89)

It hardly seems worth the net bandwidth to continue this thread, but I
seem to have generated a bit of confusion.  Of course, as several
people have pointed out, "moveto" is the obvious solution.  The
trouble is that I'd have to figure out WHERE moveto should move to.
"Arc" figures this out for itself (but doesn't tell you).  I just
wanted to avoid duplicating that work.

My solution:

/Xarc { % xc yc r a0 a1 -> xc yc r a0 a1
    4 index 4 index moveto 1 index cos 3 index mul
    2 index sin 4 index mul rmoveto
} def

Then I just plop an Xarc in front of the "arc" or "arcn" in question.
This moves the point to the start of the arc and leaves everything set
up for the arc itself.

So the answer to the original question is that (in standard
PostScript) you can't get rid of the current point without otherwise
affecting the current path.  Consequently, it's a bit more difficult
than it should be to construct a path consisting of unconnected "arc"
segments.

In NeWS (1.1), closepath DOES get rid of the current point.

It would have been easier if there were a "nukepoint" operator.  I was
surprised that PostScript didn't anticipate this particular need.  I
just assumed I was missing something obvious.

Stan Switzer  sjs@ctt.bellcore.com