Skip to main content
geng
Participant
August 12, 2021
Answered

closed curved path without doubling start/end point

  • August 12, 2021
  • 2 replies
  • 682 views

Is it possible to make a closed path (curved, no straight lines) in pure PostScript without having two equal points at start/end? I can contruct this easily in Illustrator clicking the last point onto the start point and dragging the handles, but I didn't find a way to realize it in code.

    This topic has been closed for replies.
    Correct answer Brad @ Roaring Mouse

    Ahh, okay.. so here's the thing:

    There's always 3 points involved; Your starting location, your second location, then the third location. It doesn't matter if it's the same position, it's still a third position.

    In the simple Postscript you are using, it doesn't KNOW you want to join the first and third position as a common control point; a closepath will ALWAYS add a line segment between the first and last positions.

    Even the Illustrator shape is technically 3 points, but Illustrator (and Illustrator's procset dictionary) is defining what to do with that common point, so it requires the dictionary to decode it in the program.

    When the postscript is sent to a printer, it's still 3 positions with an implied closepath which you don't see.

    2 replies

    Brad @ Roaring Mouse
    Community Expert
    Community Expert
    August 12, 2021

    Where are you seeing the result as 3 points?

    Basically, it should be as simple as:

    starting Point A (x1,y1) (move to)

    Point B x2,y2 (curve to)

    Point A x1,y1 (curve to)

    then close it (close path)

    geng
    gengAuthor
    Participant
    August 13, 2021

    After moveto, curveto, curveto there a three points, regardless of a closepath, last point sitting on top of the first one.

    Open this text (file) in Illustrator

    %!PS-Adobe-2.0 EPSF-1.2
    %%BoundingBox: 0 0 400 400
    100 200 moveto
    120 280 240 260 280 160 curveto 
    320 60 80 120 100 200 curveto closepath stroke

    Select left point, drag it away, and you can see it: three points.

     

    Legend
    August 13, 2021

    SO you are trying to test how PostScript works by importing it to Illustrator? Seems to me you could be seeing a limitation of Illustrator's import.

    Legend
    August 12, 2021

    To close a path in PostScript use "closepath". Just returning to the starting point does not close the path, however, for filling operations closure is assumed.

    geng
    gengAuthor
    Participant
    August 12, 2021

    Without returning to the starting point (last point some distance away from start point), closepath will connect  the last point with the start point by a straight line (not what I want).

    What I need is a curveto to the same location as the starting point. In that case, closepath connects these points (end on top of start) with a straight line (lenght zero), leaving two same points. Doing the same in Illustrator, I get one less point:

    The picture shows the result in Illustrator: A closed curved path with only two points.

    My question is how to achieve this with pure PostScript code. But after the second curveto, followed by a closepath I get a path with three points.

     

     

    Brad @ Roaring Mouse
    Community Expert
    Brad @ Roaring MouseCommunity ExpertCorrect answer
    Community Expert
    August 13, 2021

    Ahh, okay.. so here's the thing:

    There's always 3 points involved; Your starting location, your second location, then the third location. It doesn't matter if it's the same position, it's still a third position.

    In the simple Postscript you are using, it doesn't KNOW you want to join the first and third position as a common control point; a closepath will ALWAYS add a line segment between the first and last positions.

    Even the Illustrator shape is technically 3 points, but Illustrator (and Illustrator's procset dictionary) is defining what to do with that common point, so it requires the dictionary to decode it in the program.

    When the postscript is sent to a printer, it's still 3 positions with an implied closepath which you don't see.