RedGrittyBrick

Postscript Ellipses

Circular Arc

ellipse The width of the line varies.

Postscript

30 rotate
1 0.5 scale
0 0 2.8 inch 0 360 arc
0 0.7 0 setrgbcolor
16 setlinewidth
stroke

download

With save & set matrix

ellipse The width of the line no longer varies.

Postscript code

1 0 0 setrgbcolor
4 inch 8 inch translate
30 rotate 
0 0 2.8 inch 1.4 inch 0 360 ellipse
16 setlinewidth
stroke

Postscript function

/ellipse {
/endangle exch def
/startangle exch def
/yrad exch def
/xrad exch def
/y exch def
/x exch def
/savematrix matrix currentmatrix def
x y translate
xrad yrad scale
0 0 1 startangle endangle arc
savematrix setmatrix
} def

download

Bezier Curve

ellipse The line has constant width

Postscript code

30 rotate
2.8 inch 1.4 inch ellipse
0 0 1 setrgbcolor
16 setlinewidth
stroke

Postscript function

/ellipse {
%
% RedGrittyBrick 20/10/2003
% draw an ellipse using four bezier curves
%
/r2 exch def % 2nd parameter
/r1 exch def % 1st parameter
/kappa 0.5522847498 def

newpath
0 r2 moveto % start point of curve

% top clockwise
kappa r1 mul r2 % 1st Bezier control point
r1 kappa r2 mul % 2nd Bezier control point
r1 0 curveto    % end point of curve

% right clockwise
r1 kappa r2 mul neg
kappa r1 mul r2 neg 
0 r2 neg curveto

% bottom clockwise
kappa r1 mul neg r2 neg
r1 neg kappa r2 mul neg
r1 neg 0 curveto

% left clockwise
r1 neg kappa r2 mul
kappa r1 mul neg r2
0 r2 curveto

} def % ellipse

download

Credits

G. Adam Stanislav