home > notes > PostScript > Symbol [ printer-friendly version ]
Calendar
Bass Staff
Music Staff
Symbol

Symbol

symbol.ps

This example creates a sheet of complex geometric symbols, scaling them to different sizes.

%!PS-Adobe-2.0 EPSF-2.0
%%Title: symbol.ps
%%Pages: 1
%%Page: 1 1
% screwing around with geometric shapes
%-------------------------------------------
/Inch { 72 mul } def
/TopMargin { 0.25 Inch } def

% definition of shape (upper left corner, box width as args)
/Emblem { /Width exch def /Y exch def /X exch def

   gsave

   X Y moveto Width 0 rlineto stroke                    % top
   X Y moveto 0 Width -1 mul rlineto stroke             % left
   X Width add Y moveto 0 Width -1 mul rlineto stroke   %right
   X Y Width sub moveto Width 0 rlineto stroke          % bottom

   /CenterX { X Width 2 div add } def
   /CenterY { Y Width 2 div sub } def
   /Radius { Width 2 div 0.70 mul } def
   /StrokeWidth { Radius 4 div } def

   % Outer black circle
   StrokeWidth setlinewidth
   CenterX CenterY Radius 0 365 arc stroke

   % Calculate dimension for white triangle
   /WhiteTriangleRadius { Radius 1.375 mul } def
   /WTupprightX { CenterX WhiteTriangleRadius .866 mul add } def
   /WTupprightY { CenterY WhiteTriangleRadius .5 mul add } def
   /WTupleftX { CenterX WhiteTriangleRadius .866 mul sub } def
   /WTupleftY { WTupprightY } def
   /WTbotX { CenterX } def
   /WTbotY { CenterY WhiteTriangleRadius sub } def
   
   % draw / fill white triangle
   StrokeWidth setlinewidth
   1.0 setgray
   newpath
   WTupprightX WTupprightY moveto
   WTupleftX WTupleftY lineto
   WTbotX WTbotY lineto
   closepath
   fill

   % Calculate dimensions for inner black triangle
   /BTRadius { Radius 0.875 mul } def
   /BTuprightX { CenterX BTRadius .866 mul add } def
   /BTuprightY { CenterY BTRadius .5 mul add } def
   /BTupleftX { CenterX BTRadius .866 mul sub } def
   /BTupleftY { BTuprightY } def
   /BTbotX { CenterX } def
   /BTbotY { CenterY BTRadius sub } def

   % draw / fill black triangle
   StrokeWidth setlinewidth
   0.0 setgray
   newpath
   BTuprightX BTuprightY moveto
   BTupleftX BTupleftY lineto
   BTbotX BTbotY lineto
   closepath
   stroke

   % black dot in the middle
   0 setgray
   1 setlinewidth
   CenterX CenterY StrokeWidth 0 360 arc fill

   grestore

} def

% definition of outer border (drawing area boundary, basically)
/Boundary {
   % line across bottom of page with half-inch left-right margin
   0.25 Inch 0.25 Inch moveto 8.0 Inch 0 rlineto stroke newpath
   % line across top of page with half-inch left-right margin
   0.25 Inch 10.75 Inch moveto 8.0 Inch 0 rlineto stroke newpath
   % line up left of page with half-inch top-bottom margin
   0.25 Inch 0.25 Inch moveto 0 10.5 Inch rlineto stroke newpath
   % line up right of page with half-inch top-bottom margin
   8.25 Inch 0.25 Inch moveto 0 10.5 Inch rlineto stroke newpath
} def

%------------
newpath

Boundary

% bottom row of emblems, left to right
0.25 Inch 2.25 Inch 2 Inch Emblem
2.25 Inch 2.25 Inch 2 Inch Emblem
4.25 Inch 2.25 Inch 2 Inch Emblem
6.25 Inch 2.25 Inch 2 Inch Emblem

% next-to-bottom row, left to right
0.25 Inch 4.25 Inch 2 Inch Emblem
2.25 Inch 4.25 Inch 2 Inch Emblem
4.25 Inch 4.25 Inch 2 Inch Emblem
6.25 Inch 4.25 Inch 2 Inch Emblem

% pair of 4-inchers in the middle of the page
0.25 Inch 8.25 Inch 4 Inch Emblem
4.25 Inch 8.25 Inch 4 Inch Emblem

% row of 1-inchers
0.25 Inch 9.25 Inch 1 Inch Emblem
1.25 Inch 9.25 Inch 1 Inch Emblem
2.25 Inch 9.25 Inch 1 Inch Emblem
3.25 Inch 9.25 Inch 1 Inch Emblem
4.25 Inch 9.25 Inch 1 Inch Emblem
5.25 Inch 9.25 Inch 1 Inch Emblem
6.25 Inch 9.25 Inch 1 Inch Emblem
7.25 Inch 9.25 Inch 1 Inch Emblem

% row of 1-inchers
0.25 Inch 10.25 Inch 1 Inch Emblem
1.25 Inch 10.25 Inch 1 Inch Emblem
2.25 Inch 10.25 Inch 1 Inch Emblem
3.25 Inch 10.25 Inch 1 Inch Emblem
4.25 Inch 10.25 Inch 1 Inch Emblem
5.25 Inch 10.25 Inch 1 Inch Emblem
6.25 Inch 10.25 Inch 1 Inch Emblem
7.25 Inch 10.25 Inch 1 Inch Emblem

% row of half-inchers
0.25 Inch 10.75 Inch 0.5 Inch Emblem
0.75 Inch 10.75 Inch 0.5 Inch Emblem
1.25 Inch 10.75 Inch 0.5 Inch Emblem
1.75 Inch 10.75 Inch 0.5 Inch Emblem
2.25 Inch 10.75 Inch 0.5 Inch Emblem
2.75 Inch 10.75 Inch 0.5 Inch Emblem
3.25 Inch 10.75 Inch 0.5 Inch Emblem
3.75 Inch 10.75 Inch 0.5 Inch Emblem
4.25 Inch 10.75 Inch 0.5 Inch Emblem
4.75 Inch 10.75 Inch 0.5 Inch Emblem
5.25 Inch 10.75 Inch 0.5 Inch Emblem
5.75 Inch 10.75 Inch 0.5 Inch Emblem
6.25 Inch 10.75 Inch 0.5 Inch Emblem
6.75 Inch 10.75 Inch 0.5 Inch Emblem
7.25 Inch 10.75 Inch 0.5 Inch Emblem
7.75 Inch 10.75 Inch 0.5 Inch Emblem

showpage
quit

The definition of the symbol is pretty complex, but you can see how it is scalable for placement on the page in a variety of sizes.


home Always know how to get out of Dodge. privacy