• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

close a path for multiple curves

New Here ,
Aug 02, 2016 Aug 02, 2016

Copy link to clipboard

Copied

Hi (first time poster, user of PS approx 1 year)

I'm trying to create multiple irregular shapes and Ive found that the best way to get the shape that I want is to use the 'curveto' command. If I try to create the shape using just one curveto, the junction where the two ends meet is unnaturally pointed for what i want to create (sub-rounded stones in the bottom of a river)

Ive figured that by using two or three curveto lines and join them together, i can get the shape I want. However I cannot figure out the best way to 'fill' this multi-curveto shape with a desired color.

Is there a way to closepath on several different lines? Here is a sample of one of my shapes....

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%---Draw a irregular rock #4

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

/Rock#4

{

newpath

12 cm 15 cm moveto

10 cm 0 cm

16 cm 5 cm

19 cm 7 cm curveto

0 0 0 setrgbcolor

1 setlinewidth

%.2 setgray

stroke

newpath

12 cm 15 cm moveto

12 cm 15 cm

14 cm 25 cm

17 cm 25 cm

19 cm 18 cm curveto

0 0 0 setrgbcolor

1 setlinewidth

%.2 setgray

stroke

newpath

19 cm 18 cm moveto

12 cm 15 cm

16 cm 14 cm

20 cm 8 cm

19 cm 7 cm curveto

0 0 0 setrgbcolor

1 setlinewidth

%.2 setgray

stroke

} def

TOPICS
Programming

Views

808

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Aug 04, 2016 Aug 04, 2016

Hi, Alan -

The root of the problem is that you are constructing each of the three bezier curves as a separate path, so they are stroked and, more importantly for you, filled separately. You need to do them as a single path.

Remember that the curveto operator leaves the current point at the far end of the bezier curve. That means that you can immediately follow a call to curveto with another call to curveto. Consider these two curves:

.2 1 .5 setrgbcolor

% 1st curve

300 100 moveto

400 100

400 200

300 200

...

Votes

Translate

Translate
Explorer ,
Aug 04, 2016 Aug 04, 2016

Copy link to clipboard

Copied

Hi, Alan -

The root of the problem is that you are constructing each of the three bezier curves as a separate path, so they are stroked and, more importantly for you, filled separately. You need to do them as a single path.

Remember that the curveto operator leaves the current point at the far end of the bezier curve. That means that you can immediately follow a call to curveto with another call to curveto. Consider these two curves:

.2 1 .5 setrgbcolor

% 1st curve

300 100 moveto

400 100

400 200

300 200 curveto

fill

% 2nd curve

300 200 moveto

200 200

150 150

200 125 curveto

fill

These curves are constructed and filled separately, so they don’t end up looking like a single filled object:

Demo Pic 1.png

To fix this, we'll take advantage of the fact that the first curve, before we filled it, left the current point at 300,200; we can use that current point as the beginning of the second curve, thusly:

.2 1 .5 setrgbcolor

% 1st curve

300 100 moveto

400 100

400 200

300 200 curveto     % Leaves CP at 300,200

% 2nd curve  (starts at 300,200)

200 200

150 150

200 125 curveto

fill

We now are adding the two curves to the same path; they will fill as a single object, as you wanted.

Demo Pic 2.png

I hope this helps (and that this was what you were actually asking :-).

- John

-------

John Deubert

Acumen Training

PostScript & PDF consulting and training

john@acumentraining.com

www.acumentraining.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 05, 2016 Aug 05, 2016

Copy link to clipboard

Copied

LATEST

Great John, this worked perfectly!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines