Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %!PS
- % author codework10101@gmail.com
- % created on 06/12/2019
- % Program draws a parabola (y = x^2) in the
- % center of U.S.-Letter size (8.5 x 11 inch) paper.
- % 1 inch is 72 points, that is the length of
- % 1 inch is 72 smaller lengths called points
- % definitions
- /inch { 72 mul } def
- /pt { 1 72 div mul } def % or /pt { 72 div } def
- /cn { 255 div } def % normalize color scale to be [0, 1]
- % move scale from points to inches
- 1 inch 1 inch scale
- % move origin to center of U.S.-Letter paper (4.25 inch, 5.5 inch)
- 4.25 5.5 translate
- %=================================================
- % PARABOLA: Y = X^2, (-0.98 inch < X < +0.98 inch)
- %-------------------------------------------------
- 3 pt setlinewidth
- /n 100 def
- /dx 1 n div def % 0.01 inches
- % positive symmetry: 0 <= X < +0.98 inch
- 150 cn 206 cn 180 cn setrgbcolor
- newpath
- 0 0 moveto
- 0 1 n 1 sub {
- dx mul
- %dup == %<-- to print values uncomment this
- dup dup mul lineto
- } for
- stroke
- % negative symmetry: -0.98 inch < X < 0
- 255 cn 111 cn 105 cn setrgbcolor
- newpath
- 0 0 moveto
- 1 1 n 1 sub {
- dx mul
- -1 mul
- %dup == %<-- to print values uncomment this
- dup dup mul lineto
- } for
- stroke
- showpage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement