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
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
...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:
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.
I hope this helps (and that this was what you were actually asking :-).
- John
-------
John Deubert
Acumen Training
PostScript & PDF consulting and training
Copy link to clipboard
Copied
Great John, this worked perfectly!