🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.postscript.programming
6 messages
6 total messages Started by khoi_phamd Tue, 03 Aug 2004 22:33
creating a smooth line of xy plot graph.
#506
Author: khoi_phamd
Date: Tue, 03 Aug 2004 22:33
7 lines
880 bytes
Hi,
I'm trying to create a smooth line graph of a basic xy coordinate by
connecting a series of point.
This is done easily in excel but I can't use excel.
I try using arcto , curveto but it's not the correct solution.

Thank you, much appreciated!
Re: creating a smooth line of xy plot graph.
#508
Author: Helge_Blischke
Date: Thu, 05 Aug 2004 13:26
91 lines
2327 bytes
Perhaps you try the attached spline procedure
I've not tested it, but it looks worth a try.

%!Procedure BSpl by InterViews
/BSpl {% argument: n_pixels
0 begin
storexyn
newpath
n 1 gt {
0 0 0 0 0 0 1 1 true subspline
n 2 gt {
0 0 0 0 1 1 2 2 false subspline
1 1 n 3 sub {
/i exch def 1 sub dup i dup i 1 add dup i 2 add dup false subspline } for n 3 sub dup n 2 sub dup n 1 sub dup 2 copy false subspline
} if
n 2 sub dup n 1 sub dup 2 copy 2 copy false subspline
stroke
} if end
} dup 0 4 dict put def

/midpoint {
0 begin
/y1 exch def
/x1 exch def
/y0 exch def
/x0 exch def
x0 x1 add 2 div
y0 y1 add 2 div
end
} dup 0 4 dict put def

/thirdpoint {
0 begin
/y1 exch def
/x1 exch def
/y0 exch def
/x0 exch def
x0 2 mul x1 add 3 div
y0 2 mul y1 add 3 div
end
} dup 0 4 dict put def

/subspline {
0 begin
/movetoNeeded exch def
y exch get /y3 exch def
x exch get /x3 exch def
y exch get /y2 exch def
x exch get /x2 exch def
y exch get /y1 exch def
x exch get /x1 exch def
y exch get /y0 exch def
x exch get /x0 exch def
x1 y1 x2 y2 thirdpoint
/p1y exch def
/p1x exch def
x2 y2 x1 y1 thirdpoint
/p2y exch def
/p2x exch def
x1 y1 x0 y0 thirdpoint
p1x p1y midpoint
/p0y exch def
/p0x exch def
x2 y2 x3 y3 thirdpoint
p2x p2y midpoint
/p3y exch def
/p3x exch def
movetoNeeded { p0x p0y moveto } if
p1x p1y p2x p2y p3x p3y curveto
end
} dup 0 17 dict put def

/storexyn {
/n exch def
/y n array def
/x n array def
n 1 sub -1 0 {
/i exch def
y i 3 2 roll put
 i 3 2 roll put
} for
} def

% Example
%
% 100 100
% 150 150
% 200 125
% 250 300
% 4 BSpl
% showpage
Re: creating a smooth line of xy plot graph.
#509
Author: Miklos_Somogyi
Date: Sun, 08 Aug 2004 13:27
7 lines
934 bytes
Helge,

I find this /proc { 0 begin ... end } dup 0 4 dict put def

structure not very straightforward. Would you care to comment on it?

Miklos
Re: creating a smooth line of xy plot graph.
#510
Author: khoi_phamd
Date: Mon, 09 Aug 2004 22:18
10 lines
966 bytes
Hi Helge,
Thanks for your help.
But I get an error when I try to run your proc.
The error is on the put command. I have no idea which line.
I'm a beginer at this, so I'm still trying to figure out
your procedure.
Could you check your proc and resend it to me at
coypham@yahoo.com

Thanks!
Re: creating a smooth line of xy plot graph.
#511
Author: Helge_Blischke
Date: Tue, 10 Aug 2004 13:20
15 lines
995 bytes
Khoi,

Sorry, there is an error caused by cut & paste, obviously. Near the end of the procedure, there are two lines

y i 3 2 roll put
 i 3 2 roll put

Please change the second line to
x i 3 2 roll put


Mikos,

I just tested the proc, and it painted a spline.
I didn't try to fully understand how it works.
Re: creating a smooth line of xy plot graph.
#512
Author: khoi_phamd
Date: Tue, 10 Aug 2004 16:43
25 lines
1113 bytes
Hi Helge,
I fix the second line and I remove the comment from the example like
this.

% Example
%
100 100
150 150
200 125
250 300
4 BSpl
showpage

Then I ran the procedure, but I get this error message log.

%%[ Error: stackunderflow; OffendingCommand: sub ]%%
Stack:
1
%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
%%[ Warning: PostScript error. No PDF file produced. ] %%

Can you help?

Thanks,
Khoi
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads