Tips: EPSFでお絵描き
(expanded from EPSFを使って紙の上の正確な位置に図を描く このページは編集しないでください)
(2020/3/19)
HTMLやTeXなどを使うと簡単に綺麗な文書を作ることができるが、紙の上の正確な位置に図を描くことは難しい。HTMLだと
absolute 属性を使えば絶対位置を指定することはできるが、EPSFを使う方法を考えてみた。 EPSFはEncapsulated PostScript Fileの略で、PostScriptを他の文書に埋め込むためのフォーマットである。 たとえば、小さな正方形を描くために以下のようなEPSFを用意する。
rect.eps%!PS-Adobe-3.0 EPSF-3.0%%BoundingBox: 0 0 50 500 0 moveto0 50 lineto50 50 lineto50 0 lineto0 0 linetostroke%%Trailer%%EOF このEPSFを
rects.ps のような他のPostScriptファイルで利用することができる。rects.ps%!PS-Adobe-2.0%%Pages: 1%%BoundingBox: 0 0 595 842%%EndComments%%EndProlog%%Page: 1 1
gsave10 10 translate% ここからrect.eps%!PS-Adobe-3.0 EPSF-3.0%%BoundingBox: 0 0 50 500 0 moveto0 50 lineto50 50 lineto50 0 lineto0 0 linetostroke%%Trailer%%EOF% ここまでgrestore
gsave60 60 translate% ここからrect.eps%!PS-Adobe-3.0 EPSF-3.0%%BoundingBox: 0 0 50 500 0 moveto0 50 lineto50 50 lineto50 0 lineto0 0 linetostroke%%Trailer%%EOF% ここまでgrestore
showpage
%%Trailer%%EOF このようにすると、かなり正確に図を紙の上に印刷できると思う。