add samples and some new operators

This commit is contained in:
legoff.laurent 2010-12-13 23:01:03 +00:00
parent efd332158c
commit 07a22bace5
15 changed files with 10804 additions and 19 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 KiB

After

Width:  |  Height:  |  Size: 250 KiB

View file

@ -50,6 +50,14 @@ func foroperator(interpreter *Interpreter) {
}
}
func repeat(interpreter *Interpreter) {
proc := NewProcedure(interpreter.PopProcedureDefinition())
times := interpreter.PopInt()
for i := 0; i <= times; i++ {
proc.Execute(interpreter)
}
}
// any stopped bool -> Establish context for catching stop
func stopped(interpreter *Interpreter) {
value := interpreter.Pop()
@ -67,5 +75,6 @@ func initControlOperators(interpreter *Interpreter) {
interpreter.SystemDefine("if", NewOperator(ifoperator))
interpreter.SystemDefine("ifelse", NewOperator(ifelse))
interpreter.SystemDefine("for", NewOperator(foroperator))
interpreter.SystemDefine("repeat", NewOperator(repeat))
interpreter.SystemDefine("stopped", NewOperator(stopped))
}

View file

@ -71,6 +71,15 @@ func rcurveto(interpreter *Interpreter) {
interpreter.GetGraphicContext().RCubicCurveTo(cx1, cy1, cx2, cy2, cx3, cy3)
}
func arc(interpreter *Interpreter) {
angle2 := interpreter.PopFloat() * (math.Pi / 180.0)
angle1 := interpreter.PopFloat() * (math.Pi / 180.0)
r := interpreter.PopFloat()
y := interpreter.PopFloat()
x := interpreter.PopFloat()
interpreter.GetGraphicContext().ArcTo(x, y, r, r, angle1, angle2 - angle1)
}
func clippath(interpreter *Interpreter) {
log.Printf("clippath not yet implemented")
}
@ -280,37 +289,135 @@ func matrix(interpreter *Interpreter) {
interpreter.Push(draw2d.NewIdentityMatrix())
}
func initmatrix(interpreter *Interpreter) {
interpreter.Push(draw2d.NewIdentityMatrix())
}
func identmatrix(interpreter *Interpreter) {
tr := interpreter.Pop().(draw2d.MatrixTransform)
ident := draw2d.NewIdentityMatrix()
copy(tr[:], ident[:])
interpreter.Push(tr)
}
func defaultmatrix(interpreter *Interpreter) {
tr := interpreter.Pop().(draw2d.MatrixTransform)
ident := draw2d.NewIdentityMatrix()
copy(tr[:], ident[:])
interpreter.Push(tr)
}
func currentmatrix(interpreter *Interpreter) {
tr := interpreter.Pop().(draw2d.MatrixTransform)
ctm := interpreter.GetGraphicContext().GetMatrixTransform()
copy(tr[:], ctm[:])
interpreter.Push(tr)
}
func setmatrix(interpreter *Interpreter) {
tr := interpreter.Pop().(draw2d.MatrixTransform)
interpreter.GetGraphicContext().SetMatrixTransform(tr)
}
func concat(interpreter *Interpreter) {
tr := interpreter.Pop().(draw2d.MatrixTransform)
interpreter.GetGraphicContext().ComposeMatrixTransform(tr)
}
func concatmatrix(interpreter *Interpreter) {
tr3 := interpreter.Pop().(draw2d.MatrixTransform)
tr2 := interpreter.Pop().(draw2d.MatrixTransform)
tr1 := interpreter.Pop().(draw2d.MatrixTransform)
result := tr1.Multiply(tr2)
copy(tr3[:], result[:])
interpreter.Push(tr3)
}
func transform(interpreter *Interpreter) {
y := interpreter.PopFloat()
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var y float
if(!ok) {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
y = value.(float)
} else {
y = interpreter.PopFloat()
}
x := interpreter.PopFloat()
interpreter.GetGraphicContext().GetMatrixTransform().Transform(&x, &y)
matrix.Transform(&x, &y)
interpreter.Push(x)
interpreter.Push(y)
}
func itransform(interpreter *Interpreter) {
y := interpreter.PopFloat()
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var y float
if(!ok) {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
y = value.(float)
} else {
y = interpreter.PopFloat()
}
x := interpreter.PopFloat()
interpreter.GetGraphicContext().GetMatrixTransform().InverseTransform(&x, &y)
matrix.InverseTransform(&x, &y)
interpreter.Push(x)
interpreter.Push(y)
}
func translate(interpreter *Interpreter) {
y := interpreter.PopFloat()
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var y float
if(!ok) {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
y = value.(float)
} else {
y = interpreter.PopFloat()
}
x := interpreter.PopFloat()
interpreter.GetGraphicContext().Translate(x, y)
if(!ok) {
interpreter.GetGraphicContext().Translate(x, y)
} else {
matrix = draw2d.NewTranslationMatrix(x, y).Multiply(matrix)
interpreter.Push(matrix)
}
}
func rotate(interpreter *Interpreter) {
angle := interpreter.PopFloat()
interpreter.GetGraphicContext().Rotate(angle * (math.Pi / 180.0))
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var angle float
if(!ok) {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
angle = value.(float) * math.Pi / 180
} else {
angle = interpreter.PopFloat() * math.Pi / 180
}
if(!ok) {
interpreter.GetGraphicContext().Rotate(angle)
} else {
matrix = draw2d.NewRotationMatrix(angle).Multiply(matrix)
interpreter.Push(matrix)
}
}
func scale(interpreter *Interpreter) {
y := interpreter.PopFloat()
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var y float
if(!ok) {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
y = value.(float)
} else {
y = interpreter.PopFloat()
}
x := interpreter.PopFloat()
interpreter.GetGraphicContext().Scale(x, y)
if(!ok) {
interpreter.GetGraphicContext().Scale(x, y)
} else {
matrix = draw2d.NewScaleMatrix(x, y).Multiply(matrix)
interpreter.Push(matrix)
}
}
@ -346,6 +453,14 @@ func initDrawingOperators(interpreter *Interpreter) {
// Coordinate System and Matrix operators
interpreter.SystemDefine("matrix", NewOperator(matrix))
interpreter.SystemDefine("initmatrix", NewOperator(initmatrix))
interpreter.SystemDefine("identmatrix", NewOperator(identmatrix))
interpreter.SystemDefine("defaultmatrix", NewOperator(defaultmatrix))
interpreter.SystemDefine("currentmatrix", NewOperator(currentmatrix))
interpreter.SystemDefine("setmatrix", NewOperator(setmatrix))
interpreter.SystemDefine("concat", NewOperator(concat))
interpreter.SystemDefine("concatmatrix", NewOperator(concatmatrix))
interpreter.SystemDefine("transform", NewOperator(transform))
interpreter.SystemDefine("itransform", NewOperator(itransform))
interpreter.SystemDefine("translate", NewOperator(translate))
@ -362,5 +477,6 @@ func initDrawingOperators(interpreter *Interpreter) {
interpreter.SystemDefine("rlineto", NewOperator(rlineto))
interpreter.SystemDefine("curveto", NewOperator(curveto))
interpreter.SystemDefine("rcurveto", NewOperator(rcurveto))
interpreter.SystemDefine("arc", NewOperator(arc))
interpreter.SystemDefine("clippath", NewOperator(clippath))
}

View file

@ -91,13 +91,13 @@ func atan(interpreter *Interpreter) {
}
//angle cos real -> Return cosine of angle degrees
func cos(interpreter *Interpreter) {
a := interpreter.PopFloat()
interpreter.Push(float(math.Cos(float64(a))) * (180.0 / math.Pi))
a := interpreter.PopFloat() * math.Pi / 180
interpreter.Push(float(math.Cos(float64(a ))))
}
//angle sin real -> Return sine of angle degrees
func sin(interpreter *Interpreter) {
a := interpreter.PopFloat()
interpreter.Push(float(math.Sin(float64(a))) * (180.0 / math.Pi))
a := interpreter.PopFloat() * math.Pi / 180
interpreter.Push(float(math.Sin(float64(a))))
}
//base exponent exp real -> Raise base to exponent power
func exp(interpreter *Interpreter) {
@ -117,7 +117,7 @@ func log10(interpreter *Interpreter) {
}
// rand int Generate pseudo-random integer
func randInt(interpreter *Interpreter) {
interpreter.Push(rand.Int())
interpreter.Push(float(rand.Int()))
}
var randGenerator *rand.Rand

View file

@ -16,14 +16,26 @@ func ne(interpreter *Interpreter) {
interpreter.Push(value1 != value2)
}
func not(interpreter *Interpreter) {
b := interpreter.PopBoolean()
interpreter.Push(!b)
}
func lt(interpreter *Interpreter) {
f2 := interpreter.PopFloat()
f1 := interpreter.PopFloat()
interpreter.Push(f1 < f2)
}
func gt(interpreter *Interpreter) {
f2 := interpreter.PopFloat()
f1 := interpreter.PopFloat()
interpreter.Push(f1 > f2)
}
func initRelationalOperators(interpreter *Interpreter) {
interpreter.SystemDefine("eq", NewOperator(eq))
interpreter.SystemDefine("ne", NewOperator(ne))
interpreter.SystemDefine("not", NewOperator(not))
interpreter.SystemDefine("lt", NewOperator(lt))
interpreter.SystemDefine("gt", NewOperator(gt))
}

View file

@ -0,0 +1,57 @@
%!PS
/B {bind} bind def
/D {def} def
/Q {bind def} B D
/E {exch def} Q
/S {gsave} Q
/R {grestore} Q
/P 20 D
/N P 1 sub D
/I 1 P div D
initclip clippath pathbbox newpath
72 sub /URy E 72 sub /URx E 72 add /LLy E 72 add /LLx E
/Sq5 5 sqrt D
/F 2 Sq5 add D
/Wx URx LLx sub D /Wy URy LLy sub D
/Xx Wx 4 div D /Xy Wy F div D /X Xx Xy le {Xx}{Xy}ifelse D
Wx X 4 mul sub 2 div LLx add X 2 mul add Wy X F mul sub 2 div LLy add translate
/X X Sq5 mul D
X dup scale
0.1 X div setlinewidth
S
[ 1 .5 0 1 0 0 ] concat
0 1 N {I mul /A E
0 1 N {I mul /B E
S A B translate
newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
closepath
S I B add 1 1 A sub setrgbcolor fill R stroke % Green
R
} for
} for
R
S
[ -1 .5 0 1 0 0 ] concat
0 1 N {I mul /A E
0 1 N {I mul /B E
S A B translate
newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
closepath
S I B add 1 A sub 1 setrgbcolor fill R stroke % Blue
R
} for
} for
R
S
[ 1 .5 -1 0.5 0 1 ] concat
0 1 N {I mul /A E
0 1 N {I mul /B E
S A B translate
newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
closepath
S 1 1 B sub 1 A sub setrgbcolor fill R stroke % Red
R
} for
} for
R
showpage

View file

@ -0,0 +1,76 @@
%%% Start of L-system definition
/STARTK { FK plusK plusK FK plusK plusK FK} def
/FK {
dup 0 eq
{ DK } % if the recursion order ends, draw forward
{
1 sub % recurse
4 {dup} repeat % dup the number of parameters (order) needed.
FK minusK FK plusK plusK FK minusK FK }
ifelse
pop % pop the dup'd order
} bind def
/angleK 60 def
/minusK { % rotation to the right
angleK neg rotate
} bind def
/plusK { % rotation to the left
angleK rotate
} bind def
%%% End of L-System definition
/DK { sizeK 3 orderK exp div 0 rlineto } bind def
/thicknessK {1 orderK dup mul div} bind def
%%% Scaling factors
/orderK 3 def
/sizeK 300 def
%%% Draws a Koch's snowflake of radius 180 at 0 0
/Koch180 {
gsave
newpath
thicknessK setlinewidth
200 300 60 cos mul add
neg
200 100 60 sin mul add
neg
translate
200 200 moveto
orderK orderK orderK STARTK
stroke
closepath
grestore
} def % receives nothing
%%% Draws an arbitrary Koch's snowflake
/Koch {
/orderK exch store
gsave
3 1 roll
translate
180 div dup scale
rand 360 mod rotate
Koch180
grestore
} def % Receives x y size order
%%% Sample, bounded by an arc
400 400 100 3 Koch
newpath
400 400
100 0 360 arc
stroke
closepath
showpage

View file

@ -0,0 +1,68 @@
%!PS-Adobe-2.0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Mandelbrot set via PostScript code. Not optimized %
% in any way. Centered in A4 paper. Escape time, B&W %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/fun {
4 3 roll % y c1 c2 x
dup dup % y c1 c2 x x x
mul % y c1 c2 x x^2
5 4 roll % c1 c2 x x^2 y
dup dup mul % c1 c2 x x^2 y y^2
2 index exch sub % c1 c2 x x^2 y (x^2-y^2)
6 1 roll 2 index % (x^2-y^2) c1 c2 x x^2 y x
2 mul mul % (x^2-y^2) c1 c2 x x^2 2xy
6 1 roll % 2xy (x^2-y^2) c1 c2 x x^2
pop pop 4 1 roll % c2 2xy (x^2-y^2) c1
dup 5 1 roll add % c1 c2 2xy (x^2-y^2+c1)
4 1 roll % (x^2-y^2+c1) c1 c2 2xy
1 index % (x^2-y^2+c1) c1 c2 2xy c2
add 4 3 roll % c1 c2 (2xy+c2) (x^2-y^2+c1)
exch 4 2 roll % (x^2-y^2+c1) (2xy+c2) c1 c2
} def
/res 500 def
/iter 50 def
300 300 translate
90 rotate
-150 -260 translate
0 1 res {
/x exch def
0 1 res {
/y exch def
0 0
-2.5 4 x mul res div add
2 4 y mul res div sub
iter -1 0 {
/n exch store
fun
2 index dup mul
4 index dup mul
add sqrt
4 gt
{exit} if
} for
pop pop pop pop
n 0 gt
{1 setgray
x y 0.7 0 360 arc
fill
}
{
0 setgray
x y 0.5 0 360 arc
fill
} ifelse
} for
}for
showpage

File diff suppressed because it is too large Load diff

View file

@ -294,14 +294,14 @@ def
(RHW) show % autograph
warp 1 eq { % redefine commands to use Xform
/moveto { Xform //moveto} def
/lineto { Xform //lineto} def
/moveto { Xform moveto} bind def
/lineto { Xform lineto} bind def
/curveto {
Xform 6 -2 roll
Xform 6 -2 roll
Xform 6 -2 roll
//curveto
} def
curveto
} bind def
}if

View file

@ -0,0 +1,65 @@
%!
% grayscaled text test, including a trivial user bitmap font
/grayalphsave save def % prevent left over effects
/inch {72 mul} def
/BuildCharDict 10 dict def
/$ExampleFont 7 dict def
$ExampleFont begin
/FontType 3 def % user defined font.
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
0 1 255 {Encoding exch /.notdef put} for
Encoding (a) 0 get /plus put
/CharStrings 2 dict def
CharStrings /.notdef {} put
CharStrings /plus
{ gsave
0 0 moveto
32 32 true [32 0 0 -32 0 32]
{<0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000
0007E000 0007E000 0007E000 0007E000 0007E000 FFFFFFFF FFFFFFFF FFFFFFFF
FFFFFFFF FFFFFFFF FFFFFFFF 0007E000 0007E000 0007E000 0007E000 0007E000
0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000 0007E000>
} imagemask
grestore
} put
/BuildChar
{ BuildCharDict begin
/char exch def
/fontdict exch def
/charproc
fontdict /Encoding get char get
fontdict /CharStrings get
exch get def
1 0 0 0 1 1 setcachedevice
charproc
end
} def
end
/MyFont $ExampleFont definefont pop
newpath
.5 inch 7.5 inch moveto
7.5 inch 0 rlineto
0 1.5 inch rlineto
-7.5 inch 0 rlineto
closepath
0 setgray
fill
/MyFont findfont 72 scalefont setfont
.75 inch 7.75 inch moveto
0 1 6
{ /n exch def
1 n 6 div sub setgray
(a) show
} for
showpage
clear cleardictstack
grayalphsave restore

View file

@ -0,0 +1,939 @@
%!PS-Adobe-2.0
%%Title: Just A Little PostScript
%%Creator: Randolph J. Herber
%%CreationDate: Mon Aug 19 18:39:39 CDT 1996
%%DocumentData: Clean7Bit
%%LanguageLevel: 1
%%Pages: (atend)
%%BoundingBox: 0 0 792 612
%%Orientation: Portrait
%%PageOrder: Ascend
%%EndComments
%%BeginProlog
/DoColor true def
/Handout true def
%!
% behandler.ps, v1.3, Mar 23 1990, a modified version of Adobe's ehandler.ps
% Original program copyright (c) 1986 Adobe Systems Incorporated
% Modified by Fredric Ihren, for support contact fred@nada.kth.se or write to
% Fredric Ihren; Moerbydalen 17; S-182 32 D-RYD; Sweden
% Adobe will not keep maintenance of this program.
% Distributed with permission from Adobe Systems Incorporated
% 0000 % serverloop password
% /$brkpage where not {
% dup serverdict begin statusdict begin checkpassword
% { (NEW Error Handler downloaded.\n) print flush exitserver }
% { pop (Bad Password on loading error handler.\n) print flush stop }
% ifelse
% } {
% pop pop (NEW Error Handler in place - not loaded again\n) print flush stop
% } ifelse
/$brkpage 64 dict def
$brkpage begin
/== { /cp 0 def typeprint nl } def
/printpage {
/prnt {
dup type /stringtype ne { =string cvs } if dup length 6 mul /tx exch def
/ty 10 def currentpoint /toy exch def /tox exch def 1 setgray newpath
tox toy 2 sub moveto 0 ty rlineto tx 0 rlineto 0 ty neg rlineto
closepath fill tox toy moveto 0 setgray show
} bind def
/nl { currentpoint exch pop lmargin exch moveto 0 -10 rmoveto } def
/doshowpage systemdict /showpage get def
} def
/printonly {
/nl { (\n) print } def
/prnt { dup type /stringtype ne { =string cvs } if print } def
/doshowpage null cvx def
} def
printpage
/typeprint { dup type dup currentdict exch known
{ exec } { unknowntype } ifelse
} def
/lmargin 72 def /rmargin 72 def
/tprint { dup length cp add rmargin gt { nl /cp 0 def } if
dup length cp add /cp exch def prnt
} def
/cvsprint { =string cvs tprint( ) tprint } def
/unknowntype { exch pop cvlit (??) tprint cvsprint } def
/integertype { cvsprint } def
/realtype { cvsprint } def
/booleantype { cvsprint } def
/operatortype { (//) tprint cvsprint } def
/marktype { pop (-mark- ) tprint } def
/dicttype { pop (-dictionary- ) tprint } def
/nulltype { pop (-null- ) tprint } def
/filetype { pop (-filestream- ) tprint } def
/savetype { pop (-savelevel- ) tprint } def
/fonttype { pop (-fontid- ) tprint } def
/nametype { dup xcheck not { (/) tprint } if cvsprint } def
/stringtype {
dup rcheck
{ (\() tprint tprint (\)) tprint }
{ pop (-string- ) tprint }
ifelse
} def
/arraytype {
dup rcheck { dup xcheck
{ ({) tprint { typeprint } forall (}) tprint }
{ ([) tprint { typeprint } forall (]) tprint }
ifelse } { pop (-array- ) tprint } ifelse
} def
/packedarraytype {
dup rcheck { dup xcheck
{ ({) tprint { typeprint } forall (}) tprint }
{ ([) tprint { typeprint } forall (]) tprint }
ifelse } { pop (-packedarray- ) tprint } ifelse
} def
/stackmax 50 def
/execmax 25 def
/filemax 10 def
/courier /Courier findfont 10 scalefont def
/OLDhandleerror errordict /handleerror get def
end %$brkpage
errordict /handleerror {
systemdict begin $error begin $brkpage begin newerror {
{
/newerror false store
vmstatus pop pop 0 ne { grestoreall } if initgraphics courier setfont
lmargin 750 moveto
statusdict /jobname get dup null ne
{ (Jobname: ) prnt prnt nl } { pop } ifelse
(Error: ) prnt errorname prnt nl
(Command: ) prnt /command load ==
$error /ostack known {
$error /ostack get dup length 0 ne {
(Stack \() prnt
aload length dup prnt (\):) prnt nl
/i 0 def
{ /i i 1 add def i stackmax le { == } { pop } ifelse }
repeat
} { pop } ifelse
} if
$error /estack known {
$error /estack get dup dup length 1 sub get type /filetype ne {
(Execstack \() prnt
aload length dup prnt (\):) prnt nl
/i 0 def
{ /i i 1 add def dup type /filetype eq { /i 99 def } if
i execmax le { == } { pop } ifelse
} repeat
} { pop } ifelse
} if
(%stdin) (r) file
dup =string readline {
(File:) prnt nl prnt nl
filemax 1 sub { dup =string readline { prnt nl } { exit } ifelse }
repeat
} if pop
userdict /debug known {
(Debug:) prnt nl
userdict /debug get stopped pop nl
} if
} stopped pop
doshowpage
/newerror true store
/OLDhandleerror load end end end exec
} { end end end }
ifelse
} dup 0 systemdict put dup 4 $brkpage put bind put
/PageFrame 600 dict dup begin
%%Copyright: Copyright 1991 University Research Associates.
%%+ ***************************************************************************
%%+ ** Copyright (c) 1991 Randolph J. Herber **
%%+ ** All Rights Reserved. **
%%+ ** Applies only to the included type 3 font **
%%+ ** describing the Fermilab logo. **
%%+ ** The type 3 font was developed using personal **
%%+ ** equipment and own time and materials. **
%%+ ** The following license granted to the **
%%+ ** Government. **
%%+ ** Copyright (c) 1991 Universities Research Association, Inc. **
%%+ ** All Rights Reserved. **
%%+ ** **
%%+ ** This material resulted from work developed under a Government **
%%+ ** Contract and is subject to the following license: **
%%+ ** **
%%+ ** LICENSE **
%%+ ** The Government retains a paid-up, nonexclusive, irrevocable worldwide **
%%+ ** license to reproduce, prepare derivative works, perform publicly and **
%%+ ** display publicly by or for the Government, including the right to **
%%+ ** distribute to other Government contractors. Neither the **
%%+ ** United States nor the United States Department of Energy nor any of **
%%+ ** their employees, nor the author of the type 3 font included makes **
%%+ ** any warranty, express or implied, or assumes any legal liability or **
%%+ ** responsibility for the accuracy, completeness, or usefulness of any **
%%+ ** information, apparatus, product, or process disclosed, or represents **
%%+ ** that its use would not infringe privately owned rights. **
%%+ ** **
%%+ ** **
%%+ ** Fermilab Computing Division/Distributed Computing Department **
%%+ ** **
%%+ ***************************************************************************
%%
%% Begining of Logo font definition
%%
9 dict dup begin
/FontType 3 def
/FontName (Logo) cvn def
/FontMatrix [0.001 0 0 0.001 0 0] def
/FontBBox [0 0 0 0] def % Some interperters need this
/Encoding 256 array def
0 1 255 { Encoding exch /.notdef put } bind for
Encoding
dup 70 /Fermi put
pop
/CharProcs 7 dict dup begin
/Fermi {
0 setlinecap
0 setlinejoin
1 setlinewidth
1000 0 0 0 1000 1000 setcachedevice
475 887.5 moveto
0 80.88 rlineto
-150 0 rlineto
0 -93.38 rlineto
-155.72 0 rlineto
0 -150 rlineto
154.46 0 rlineto
262.5 737.5 62.5 348.46 270 arcn
-230.88 0 rlineto
0 -150 rlineto
230.88 0 rlineto
262.5 737.5 212.5 270 360 arc
50 0 rlineto
737.5 737.5 212.5 180 270 arc
230.88 0 rlineto
0 150 rlineto
-230.88 0 rlineto
737.5 737.5 62.5 270 191.54 arcn
154.46 0 rlineto
0 150 rlineto
-155.72 0 rlineto
0 93.38 rlineto
-150 0 rlineto
0 -80.88 rlineto fill
525 112.5 moveto
0 -80.88 rlineto
150 0 rlineto
0 93.38 rlineto
155.72 0 rlineto
0 150 rlineto
-154.46 0 rlineto
737.5 262.5 62.5 168.46 90 arcn
230.88 0 rlineto
0 150 rlineto
-230.88 0 rlineto
737.5 262.5 212.5 90 180 arc
-50 0 rlineto
262.5 262.5 212.5 0 90 arc
-230.88 0 rlineto
0 -150 rlineto
230.88 0 rlineto
262.5 262.5 62.5 90 11.54 arcn
-154.46 0 rlineto
0 -150 rlineto
155.72 0 rlineto
0 -93.38 rlineto
150 0 rlineto
0 80.88 rlineto fill
} bind def
end def
/BuildChar {
0
begin
exch begin
Encoding exch get
CharProcs exch get
end
exec
end
} bind def
/BuildChar load 0
6 dict dup begin
end put
end
/Logo exch definefont pop
%
% Copyright 1990 by Adobe Systems Incorporated. All rights reserved.
%
% This file may be freely copied and redistributed as long as:
% 1) This entire notice continues to be included in the file,
% 2) If the file has been modified in any way, a notice of such
% modification is conspicuously indicated.
%
% PostScript, Display PostScript, and Adobe are registered trademarks of
% Adobe Systems Incorporated.
%
% ************************************************************************
% THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO CHANGE WITHOUT
% NOTICE, AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY ADOBE SYSTEMS
% INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR
% LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY
% KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION,
% AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
% ************************************************************************
%
% This file defines a PostScript procedure called "R" which will
% reencode a font. It expects to find three things on the operand stack:
%
% [ array ] /NewName /OldName
%
% The array should contain pairs of <number> <name>, like "32 /space",
% each of which will define a slot in the encoding and the name to put
% in that slot. Only those names which are needed to over-ride the
% existing ones need be specified. An encoding value (number) may
% be specified followed by more than one name, like "128 /name1 /name2".
% In this case, the names will be sequentially stored in the encoding
% starting at the initial number given (128).
/R {
findfont begin currentdict dup length dict begin
{ %forall
1 index /FID ne {def} {pop pop} ifelse
} forall
/FontName exch def dup length 0 ne { %if
/Encoding Encoding 256 array copy def
0 exch { %forall
dup type /nametype eq { %ifelse
Encoding 2 index 2 index put
pop 1 add
}{ %else
exch pop
} ifelse
} forall
} if pop
currentdict dup end end
/FontName get exch definefont pop
} bind def
% sample use:
% [ 8#360 /apple ] /_Symbol /Symbol R
% declare page sizes
/D {def} bind def
/B {bind D} bind D
/E {exch D} B
/M {moveto} B
/S {marking {show}
{stringwidth rmoveto
currentpoint pop dup MaxX gt{/MaxX E}{pop}ifelse}
ifelse} B
/H {marking {currentlinewidth exch true charpath 0.5 setlinewidth
gsave 1 setgray fill grestore stroke setlinewidth}
{stringwidth rmoveto
currentpoint pop dup MaxX gt{/MaxX E}{pop}ifelse}
ifelse} B
/Stroke {currentpoint pop dup MaxX gt{/MaxX E}{pop}ifelse marking {stroke}if} B
/W {stringwidth pop} B
/Short 612 D
/Long 792 D
% at this point in the program, the default coordinate system is still in place
/Shrink where {pop
Short 1.0 Shrink sub 0.5 mul mul Long 1.0 Shrink sub 0.5 mul mul translate
Shrink Shrink scale} if
/margin 36 D
/logosize 48 D % memo head size is 56.25
/radius 18 D
/gap 12 D
/offset 8 D
/High 480 D
/Wide 720 D
/CenterX 396 D
/CenterY 336 D
/Top CenterY High 0.5 mul add D
/Tsize 36 D
/Tlead 9 D
/Tspace Tsize Tlead add D
/esize 18 D
/elead 6 D
/espace esize elead add D
/tsize 18 D
/tlead 6 D
/tspace tsize tlead add D
/Ssize 6 D
/Slead 2 D
/Sspace Ssize Slead add D
/setline {1 sub /lineno E} B
/LT {/lineno exch def lineno Lmax gt {/Lmax lineno def}if} B
/eT {/lineno exch def lineno emax gt {/emax lineno def}if} B
/lT {/lineno exch def lineno lmax gt {/lmax lineno def}if} B
/Line {LT lineno 1 sub Tspace mul Base exch sub /Y E} B
/L+ {lineno 1 add LT lineno 1 sub Tspace mul Base exch sub /Y E} B
/L+2 {lineno 2 add LT lineno 1 sub Tspace mul Base exch sub /Y E} B
/eline {eT lineno 1 sub espace mul ebase exch sub /Y E} B
/e+ {lineno 1 add eT lineno 1 sub espace mul ebase exch sub /Y E} B
/e+2 {lineno 2 add eT lineno 1 sub espace mul ebase exch sub /Y E} B
/line {lT lineno 1 sub tspace mul base exch sub /Y E} B
/l+ {lineno 1 add lT lineno 1 sub tspace mul base exch sub /Y E} B
/l+2 {lineno 2 add lT lineno 1 sub tspace mul base exch sub /Y E} B
/C1 {col1 Y moveto} B
/C2 {col2 Y moveto} B
/C3 {col3 Y moveto} B
/C4 {col4 Y moveto} B
/C5 {col5 Y moveto} B
/C6 {col6 Y moveto} B
/C7 {col7 Y moveto} B
/C8 {col8 Y moveto} B
/C9 {col9 Y moveto} B
/RC [ 8#375 /copyright /registered /trademark ] def
RC /_Times-Roman /Times-Roman R
/foliofont /_Times-Roman findfont logosize offset 3 mul sub scalefont D
/FO {foliofont setfont} B
/textsize /_Times-Roman findfont tsize scalefont D
/TX {textsize setfont} B
/TXS {currentfont exch TX S setfont} B
RC /_Times-Italic /Times-Italic R
/italics /_Times-Italic findfont tsize scalefont D
/TI {italics setfont} B
/TIS {currentfont exch TI S setfont} B
RC /_Times-BoldItalic /Times-BoldItalic R
/bold_italics /_Times-BoldItalic findfont tsize scalefont D
/TJ {bold_italics setfont} B
/TJS {currentfont exch TJ S setfont} B
RC /_Times-Bold /Times-Bold R
/boldfont /_Times-Bold findfont tsize scalefont D
/TB {boldfont setfont} B
/TBS {currentfont exch TB S setfont} B
/monospace /Courier-Bold findfont tsize scalefont D
/CM {monospace setfont} B
/CMS {currentfont exch CM S setfont} B
/monolite /Courier findfont tsize scalefont D
/CR {monolite setfont} B
/CRS {currentfont exch CR S setfont} B
/monoitalic /Courier-Oblique findfont tsize scalefont D
/CI {monoitalic setfont} B
/CIS {currentfont exch CI S setfont} B
/monoBI /Courier-BoldOblique findfont tsize scalefont D
/CJ {monoBI setfont} B
/CJS {currentfont exch CJ S setfont} B
/narrowmono /Courier-Bold findfont [.8 tsize mul 0 0 tsize 0 0] makefont D
/SC {narrowmono setfont} B
/SCS {currentfont exch SC S setfont} B
/largesize /_Times-Roman findfont Tsize scalefont D
/LG {largesize setfont} B
/LGS {currentfont exch LG S setfont} B
/smallfont /_Times-Roman findfont Ssize scalefont D
/SM {smallfont setfont} B
/SMS {currentfont exch SM S setfont} B
/symbolfont /Symbol findfont tsize scalefont D
/SY {symbolfont setfont} B
/microsymbol /Symbol findfont tsize 0.4 mul scalefont D
/MY {microsymbol setfont} B
/pointerfont /ZapfDingbats findfont tsize scalefont D
/PT {pointerfont setfont} B
/FNALfont /Logo findfont tsize scalefont D
/FN {FNALfont setfont} B
/Item {currentfont SY(\267)S setfont} B
/Note {currentfont PT(-)S setfont} B
/Here {currentfont PT(+)S setfont} B
/Gives {currentfont SY(\336)S setfont} B
/Moon {currentfont PT(m)S setfont} B
/FNAL {currentfont FN(F)S setfont} B
/Block1 {currentfont PT(y)S setfont} B
/Block2 {currentfont PT(z)S setfont} B
/Start {currentpoint gsave currentpoint translate MY (\355) stringwidth
pop -.5 mul tsize -.5 mul moveto (\255) S grestore moveto } B
/Mark {currentpoint gsave currentpoint translate MY (\355) stringwidth
pop -.5 mul tsize -.5 mul moveto (\335) S grestore moveto } B
/More {660 108 M currentfont TX ((more)) show setfont} B
/center {/Text E Long Text stringwidth pop sub 0.5 mul exch moveto
Text marking{show}{pop}ifelse} B
/Center {Long exch sub 0.5 mul exch moveto} B
/Fickle {Index lineno eq {Here} {Item} ifelse} B
/RVS {marking {dup save exch currentpoint newpath moveto
1 0 rmoveto true charpath pathbbox
1 add /Uy E 1 add /Ux E 1 sub /Ly E 1 sub /Lx E newpath
Lx Ux add 0.5 mul Ly moveto
Lx Ly Lx Uy 1 arcto pop pop pop pop
Lx Uy Ux Uy 1 arcto pop pop pop pop
Ux Uy Ux Ly 1 arcto pop pop pop pop
Ux Ly Lx Ly 1 arcto pop pop pop pop
closepath
0 setgray fill restore
currentgray exch 1 setgray 1 0 rmoveto show 1 0 rmoveto setgray}
{stringwidth rmoveto 2 0 rmoveto
currentpoint pop dup MaxX gt{/MaxX E}{pop}ifelse}
ifelse} B
/Frame {
/ll E /el E /Ll E
/Lmax 0 D /emax 0 D /lmax 0 D
/Gaps 1 Ll 1 lt{0 /THght 0 D}{1 /THght Ll Tspace mul Tlead sub D}ifelse add
el 1 lt{0 /eHght 0 D}{1 /eHght el espace mul elead sub D}ifelse add
ll 1 lt{0 /tHght 0 D}{1 /tHght ll tspace mul tlead sub D}ifelse add D
/GapSize High THght sub eHght sub tHght sub Gaps div D
/Base Top Ll 1 ge{GapSize sub Tsize sub}if D
/ebase Top Ll 1 ge{GapSize sub THght sub}if
el 1 ge{GapSize sub esize sub}if D
/base Top Ll 1 ge{GapSize sub THght sub}if
el 1 ge{GapSize sub eHght sub}if
ll 1 ge{GapSize sub tsize sub}if D
/Rnd {rand 2147483647.0 div mul add} bind def
% size of rounded box allowing for logo at top
/boxx Long margin dup add sub D
/boxy Short margin dup add sub logosize sub gap sub D
% left edge of logo area
/logox Long margin sub logosize 1.2 mul sub
/Helvetica-Bold findfont logosize 0.5 mul scalefont setfont (Fermilab)
stringwidth pop sub D
% left edge of titling area
/titlesize logosize 6 div D
/titlefont /Helvetica-Bold findfont titlesize 1.6 mul scalefont D
/giverfont /Times-Roman findfont titlesize 0.8 mul scalefont D
/titlex logox gap sub
titlefont setfont talktitle stringwidth pop
giverfont setfont talkgiver stringwidth pop 2 copy lt {exch} if pop
talkdept stringwidth pop 2 copy lt {exch} if pop
talkaddr stringwidth pop 2 copy lt {exch} if pop
talkcopyr stringwidth pop 2 copy lt {exch} if pop
sub D
% determine folio box size
/folioboxx foliofont setfont folio stringwidth pop offset dup add add D
/folioboxy logosize offset sub D
% determine folio box x origin
/folioorgx titlex margin add gap sub offset sub folioboxx sub 2 div D
% rotate to landscape orientation
90 rotate
% move origin to lower left hand corner of sheet
0 Short neg translate
% draw logo in lower right hand corner
save
/DoColor where {pop DoColor {.4 .6 Rnd .2 .8 Rnd .2 .8 Rnd setrgbcolor}if}if
logox margin translate
/Logo findfont logosize scalefont setfont 0 0 moveto (F) show
/DoColor where {pop DoColor {0 setgray}if}if
/Helvetica-Bold findfont
logosize 0.5 mul scalefont setfont
logosize 1.2 mul logosize 0.375 mul moveto
(Fermilab) show
restore
% add talk data
save
titlex margin translate
0 titlesize 4 mul moveto titlefont setfont talktitle show
0 titlesize 3 mul moveto giverfont setfont talkgiver show
0 titlesize 2 mul moveto talkdept show
0 titlesize moveto talkaddr show
0 0 moveto talkcopyr show
restore
% add folio
save
0 setlinecap % square butt ends
1 setlinejoin % rounded corners
0.5 setlinewidth % width of line to draw
/box {1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath} B
folioorgx margin translate
gsave
offset 0 translate 0 0 moveto 0 setgray folioboxx folioboxy box fill
grestore
gsave
0 offset translate
0 0 moveto 0.95 setgray folioboxx folioboxy box fill
0 0 moveto 0 setgray folioboxx folioboxy box stroke
grestore
gsave
offset dup dup add translate 0 0 moveto foliofont setfont
folio true charpath
gsave 1 setgray fill grestore stroke
grestore
restore
%
% draw rounded box
%
save
/DoColor where {pop DoColor {0 0 1 setrgbcolor}if}if
% start a new path
% line characters
0 setlinecap % square butt ends
1 setlinejoin % rounded corners
3 setlinewidth % width of line to draw
newpath
% make lower left corner of the rounded box the origin
margin margin logosize add gap add translate
% center of bottom edge
boxx 0.5 mul 0 moveto
% draw lower left corner to center of left edge
0 0 0 boxy mul 0.5 radius arcto pop pop pop pop
% draw upper left corner to center of top edge
0 boxy boxx 0.5 mul boxy radius arcto pop pop pop pop
% draw upper right corner to center of right edge
boxx boxy boxx boxy 0.5 mul radius arcto pop pop pop pop
% draw lower left corner to near center of bottom edge
boxx 0 boxx mul 0.5 6 add 0 radius arcto pop pop pop pop
% close the path
closepath
% draw the box
stroke
restore
save
filenames {756 SM filename stringwidth pop sub 588 moveto filename show}if
restore} B
/Check {
filenames {
Lmax dup add emax add lmax add 18 lt
{Lmax Ll ne emax el ne or lmax ll ne or}
{Lmax Ll ne emax el ne or lmax 1 add ll ne or} ifelse
{ 36 588 moveto SM
Lmax =string cvs show (/)show Ll =string cvs show ( )show
emax =string cvs show (/)show el =string cvs show ( )show
lmax =string cvs show (/)show ll =string cvs show
} if
} if } B
%
% draw rounded box
%
/drbradius tsize 3 div D
/drb { /drbtext E /drbxy E /drbxx E
marking
{ save
currentpoint translate
0 setlinecap % square butt ends
1 setlinejoin % rounded corners
0.5 setlinewidth % width of line to draw
newpath
% the origin is the lower left corner of the rounded box
% start drawing the box at the center of the bottom edge
drbxx 0.5 mul 0 moveto
% draw lower left corner to center of left edge
0 0 0 drbxy mul 0.5 drbradius arcto pop pop pop pop
% draw upper left corner to center of top edge
0 drbxy drbxx 0.5 mul drbxy drbradius arcto pop pop pop pop
% draw upper right corner to center of right edge
drbxx drbxy drbxx drbxy 0.5 mul drbradius arcto pop pop pop pop
% draw lower left corner to near center of bottom edge
drbxx 0 drbxx mul 0.5 6 add 0 drbradius arcto pop pop pop pop
% close the path
closepath
% draw the box
stroke
% place the text
drbxx drbtext stringwidth pop sub 0.5 mul
drbxy tspace sub 0.5 mul tlead add
moveto drbtext show
restore
}{
/drbright currentpoint pop drbxx add 0.25 add D
drbright MaxX gt {/MaxX drbright D} if
} ifelse
} B
/PlaceText {
/Markings E
save /marking false D /MaxX 0 D Markings
CenterX MaxX 0.5 mul sub 0 translate
/marking true D Markings lmax exch restore /lmax exch def} B
/MeasureText {/Markings E /marking false D /MaxX 0 D /Base Top D /base Top D
Markings /OffsetX CenterX MaxX 0.5 mul sub D} B
/MarkText {save OffsetX 0 translate /marking true D Markings restore} B
/marking true D
/filenames false D
/OffsetX 90 D
/col1 0 D
/col2 30 D
/col3 60 D
/col4 90 D
/col5 120 D
/col6 150 D
/col7 180 D
/col8 210 D
/col9 240 D
%%
%% Used to divide the page into two sections divided horizonally
%%
/Scale 0.625 D
/SubPageX Short Scale mul D
/SubPageY Long Scale mul D
/AdjustX -6 D
/AdjustUX Long -0.5 mul AdjustX sub SubPageX sub D
/AdjustLX Long -0.5 mul AdjustX add D
/AdjustY Short SubPageY sub 0.5 mul D
/Upper{Handout
{-90 rotate AdjustUX AdjustY translate Scale Scale scale }if}B
/Lower{Handout
{-90 rotate AdjustLX AdjustY translate Scale Scale scale }if}B
%%
%% Used to print handout format text
%%
/LineBuffer 128 string D
/in{72 mul}B /mm{2.8346 mul}B /pt{}B /by{}B
/PageSize{/long E /short E}B
/land{90 rotate 0 short neg translate /High short D /Wide long D}B
/port{/High long D /Wide short D}B
/Offset{/Yoff E /Xoff E Xoff Yoff translate
/High High Yoff sub Yoff sub D /Wide Wide Xoff sub Xoff sub D}B
/LineSize{/Lhigh E /Lwide E
/Lvert High Lhigh div cvi D /Lhori Wide Lwide div cvi D}B
/SetFont{findfont exch /FS E [ .8 FS mul 0 0 FS 0 0 ] makefont setfont}B
/R3{3 1 roll}B
/DC{2 index Lhori 1 sub ge
{NewPage pop pop 0 Lvert false}
{R3 pop Lvert R3 1 add R3}ifelse}B
/DR{1 index 0 le{DC}if exch 1 sub exch}B
/T{exch pop true exch 3 index Lwide mul 3 index Lhigh mul M show}B
/ReadLine {currentfile LineBuffer readline exch /Text E not Text EOF eq or}B
%
% Sheet description
%
/NoteText{/EOF E Handout
{8.5 in by 11 in PageSize land 36 36 Offset
360 pt by 12 pt LineSize 11 /Courier-Bold SetFont
save 0 Lvert false
{ReadLine {exit}{DR Text length 0 ne {Text T}if}ifelse}loop
pop pop pop restore}
{{ReadLine {exit}if}loop}
ifelse restore}B
/Viewgraph {save Upper} B
/EndViewgraph {Check restore} B
/Notes {save Lower (EndNotes) NoteText} B
end def
/PageTop {PageFrame begin save 100 dict begin} bind def
/PageBottom {end restore end} bind def
/DoColor where {pop}{/DoColor false def}ifelse
/Handout where {pop}{/Handout false def}ifelse
% titling data
/talktitle (Just a little PostScript) def
/talkgiver (Randolph J. Herber, herber@fnal.fnal.gov, 1 630 840 2966 CDF PK149O)
def
/talkdept (Computing Division/Operating System Support/CDF Task Force) def
/talkaddr (P.O. Box 500, Mail Stop 234 (WH6W), Batavia, IL 60510) def
/talkcopyr () def
/filenames true def
%%EndProlog
%%Page: Examples12 1
PageTop
Viewgraph
/folio (Examples) def
/filename (examples.12) def
/@ {transform .5 add floor exch .5 add floor exch itransform} bind def
/! {dtransform .5 add floor exch .5 add floor exch idtransform} bind def
1 0 19 Frame
LG 1 Line Y (Many different ways to draw two parallel lines) center
8 line save /showpage {} def 146 Y @ translate .2 dup scale
gsave newpath 0 0 moveto 612 0 rlineto 0 792 rlineto -612 0 rlineto closepath
DoColor{0 0 1 setrgbcolor}if stroke grestore
66 146 @ translate
2 setlinewidth
0 0 @ moveto 500 0 ! rlineto stroke
0 500 @ moveto 500 0 ! rlineto stroke
showpage
restore
8 line save /showpage {} def 271 Y @ @ translate .2 dup scale
gsave newpath 0 0 moveto 612 0 rlineto 0 792 rlineto -612 0 rlineto closepath
DoColor{0 0 1 setrgbcolor}if stroke grestore
66 146 @ translate
2 setlinewidth
0 0 @ moveto
gsave
0 500 @ moveto 500 0 ! rlineto stroke
grestore
500 0 ! rlineto stroke
showpage
restore
8 line save /showpage {} def 396 Y @ translate .2 dup scale
gsave newpath 0 0 moveto 612 0 rlineto 0 792 rlineto -612 0 rlineto closepath
DoColor{0 0 1 setrgbcolor}if stroke grestore
66 146 @ translate
2 setlinewidth
[500] 0 setdash
0 0 @ moveto 500 0 ! rlineto 0 500 ! rlineto -500 0 ! rlineto closepath stroke
showpage
restore
8 line save /showpage {} def 521 Y @ translate .2 dup scale
gsave newpath 0 0 moveto 612 0 rlineto 0 792 rlineto -612 0 rlineto closepath
DoColor{0 0 1 setrgbcolor}if stroke grestore
66 146 @ translate
2 setlinewidth
[50] 0 setdash
0 0 @ moveto 500 0 ! rlineto stroke
500 500 @ moveto -500 0 ! rlineto stroke
500 0 @ moveto -500 0 ! rlineto stroke
0 500 @ moveto 500 0 ! rlineto stroke
showpage
restore
16 line save /showpage {} def 146 Y @ translate .2 dup scale
gsave newpath 0 0 moveto 612 0 rlineto 0 792 rlineto -612 0 rlineto closepath
DoColor{0 0 1 setrgbcolor}if stroke grestore
66 146 @ translate
2 setlinewidth
[50] 0 setdash
.2 setgray 0 0 @ moveto 500 0 ! rlineto stroke
.4 setgray 500 500 @ moveto -500 0 ! rlineto stroke
.6 setgray 500 0 @ moveto -500 0 ! rlineto stroke
.8 setgray 0 500 @ moveto 500 0 ! rlineto stroke
showpage
restore
16 line save /showpage {} def 271 Y @ translate .2 dup scale
gsave newpath 0 0 @ moveto 612 0 rlineto 0 792 rlineto -612 0 rlineto closepath
DoColor{0 0 1 setrgbcolor}if stroke grestore
66 146 @ translate
/B {bind def} dup exec
/E {exch def} B
/Box {/W E /H E
@ moveto W 0 ! rlineto 0 H ! rlineto W neg 0 ! rlineto closepath} B
0 -1 2 500 Box 0 499 2 500 Box fill
showpage
restore
16 line save /showpage {} def 390 Y @ translate .2 dup scale
gsave newpath 0 0 @ moveto 612 0 rlineto 0 792 rlineto -612 0 rlineto closepath
DoColor{0 0 1 setrgbcolor}if stroke grestore
66 146 @ translate
/B {bind def} dup exec
/E {exch def} B
/Box {/W E /H E
@ moveto W 0 ! rlineto 0 H ! rlineto W neg 0 ! rlineto closepath} B
0 -2 504 500 Box fill 1 setgray 0 1 498 500 Box fill
showpage
restore
16 line save /showpage {} def 521 Y @ translate .2 dup scale
gsave newpath 0 0 @ moveto 612 0 rlineto 0 792 rlineto -612 0 rlineto closepath
DoColor{0 0 1 setrgbcolor}if stroke grestore
66 146 @ translate
2 setlinewidth
[5] 0 setdash
newpath
500 0 0 0 -500 0 500 500 -500 0 500 0 500 0 0 500
4 {@ moveto ! rlineto} bind repeat
stroke
showpage
restore
{
18 setline TX
l+ C1(These look alike and have vastly different PostScript language codes.)S
} PlaceText
EndViewgraph
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Notes lines should not be longer than 65 characters. %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Notes
==> Q1.ps <==
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 55 145 557 647
%%Pages: 1
%%EndComments
66 146 translate 2 setlinewidth
0 0 moveto 500 0 rlineto stroke
0 500 moveto 500 0 rlineto stroke
showpage
==> Q2.ps <==
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 55 145 557 647
%%Pages: 1
%%EndComments
66 146 translate 2 setlinewidth
0 0 moveto gsave 0 500 moveto 500 0 rlineto stroke
grestore 500 0 rlineto stroke
showpage
==> Q3.ps <==
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 55 145 557 647
%%Pages: 1
%%EndComments
66 146 translate 2 setlinewidth [500] 0 setdash
0 0 moveto 500 0 rlineto 0 500 rlineto -500 0 rlineto
closepath stroke
showpage
==> Q4.ps <==
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 55 145 557 647
%%Pages: 1
%%EndComments
66 146 translate 2 setlinewidth [50] 0 setdash
0 0 moveto 500 0 rlineto stroke
500 500 moveto -500 0 rlineto stroke
500 0 moveto -500 0 rlineto stroke
0 500 moveto 500 0 rlineto stroke
showpage
==> Q5.ps <==
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 55 145 557 647
%%Pages: 1
%%EndComments
66 146 translate 2 setlinewidth [50] 0 setdash
.2 setgray 0 0 moveto 500 0 rlineto stroke
.4 setgray 500 500 moveto -500 0 rlineto stroke
.6 setgray 500 0 moveto -500 0 rlineto stroke
.8 setgray 0 500 moveto 500 0 rlineto stroke
showpage
==> Q6.ps <==
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 55 145 557 647
%%Pages: 1
%%EndComments
66 146 translate /B {bind def} dup exec /E {exch def} B
/Box {/W E /H E moveto
W 0 rlineto 0 H rlineto W neg 0 rlineto closepath} B
0 -1 2 500 Box 0 499 2 500 Box fill
showpage
==> Q7.ps <==
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 55 145 557 647
%%Pages: 1
%%EndComments
66 146 translate /B {bind def} dup exec /E {exch def} B
/Box {/W E /H E moveto
W 0 rlineto 0 H rlineto W neg 0 rlineto closepath} B
0 -1 502 500 Box fill 1 setgray 0 1 498 500 Box fill
showpage
==> Q8.ps <==
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 55 145 557 647
%%Pages: 1
%%EndComments
66 146 translate 2 setlinewidth [5] 0 setdash newpath
500 0 0 0 -500 0 500 500 -500 0 500 0 500 0 0 500
4 {moveto rlineto} bind repeat stroke
showpage
EndNotes
showpage
PageBottom
%%EOF

275
postscript-go/test_files/maze.ps Executable file
View file

@ -0,0 +1,275 @@
%!PS
%%Pages: 1
%%EndComments
% Yet Another Maze Maker
% Version 2
% Written by Peter Sorotokin, 1996-1998
% This program is in the public domain.
% Note: do not send this job to the printer until you know
% how to cancel it (it may take a LOT of time on slow printer;
% it takes couple minutes on my LaserJet 4).
%%BeginSetup
% put your sizes here:
/width 25 def
/height 25 def
% seed number here:
0 srand % put your seed number instead of 0 (normally not required)
systemdict /realtime known { realtime srand } if
% initialization
/size width height mul def
/zone size array def
/zsize size array def
/vert width 1 add array def
/hor height 1 add array def
/w1 width 1 sub def
/h1 height 1 sub def
0 1 size 1 sub { dup zsize exch 1 put zone exch dup put } bind for
0 1 width { vert exch height string 0 1 h1
{ 1 index exch 255 put } for put } bind for
0 1 height { hor exch width string 0 1 w1
{ 1 index exch 255 put } for put } bind for
% define subroutines
/db { dup 20 string cvs = } bind def
/find_set { { zone 1 index get dup 3 1 roll eq {exit} if } loop} bind def
/merge_sets {
2 copy zsize exch get
exch zsize exch get 2 copy gt
3 1 roll add exch
{ zsize 2 index 3 -1 roll put
zone 3 1 roll put }
{ zsize 3 index 3 -1 roll put
zone 3 1 roll exch put }
ifelse } bind def
%%EndSetup
%%Page: maze 1
% building
size 1 sub
{
{
rand 2 mod 0 eq
{
rand height mod
rand w1 mod 2 copy
height mul add
dup height add
find_set exch find_set
2 copy eq
{
pop pop pop pop
}
{
merge_sets vert exch 1 add get exch 0 put exit
}
ifelse
}
{
rand h1 mod
rand width mod 2 copy
height mul add
dup 1 add
find_set exch find_set
2 copy eq
{
pop pop pop pop
}
{
merge_sets exch hor exch 1 add get exch 0 put exit
}
ifelse
}
ifelse
}
loop
} bind repeat
% make entrance and exit
vert 0 get rand height mod 0 put
vert width get rand height mod 0 put
% setup output
clippath pathbbox
2 index sub exch
3 index sub exch
4 2 roll translate
2 copy height 4 add div exch width 4 add div
2 copy gt {exch} if pop /myscale exch def
myscale height mul sub 2 div exch
myscale width mul sub 2 div exch
translate
myscale myscale scale
0.05 setlinewidth
newpath
% render the maze
0 1 width { dup 0 moveto vert exch get 0 1 height 1 sub
{ 1 index exch get 0 eq 0 1 3 -1 roll { rmoveto } { rlineto } ifelse }
for pop } bind for
0 1 height { dup 0 exch moveto hor exch get 0 1 width 1 sub
{ 1 index exch get 0 eq 1 0 3 -1 roll { rmoveto } { rlineto } ifelse }
for pop } bind for
stroke
stroke
% Quick hack to solve the maze.
% This part written by Christian Lehner.
clear
/NORTH 1 def
/WEST 2 def
/SOUTH 4 def
/EAST 8 def
/CRUMB 16 def
/find_door {% column => index
dup 0 1 3 -1 roll length 1 sub {
2 copy get 0 eq {
exch pop
exit
} {
pop
} ifelse
} for
} bind def
/mentrance vert 0 get find_door def
/mexit vert width get find_door def
/maze [height {[width {0} repeat]} repeat] def
/mget {% row col => int
maze 3 -1 roll get exch get
} bind def
/mset {% row col int => -
maze 4 -1 roll get 3 -2 roll put
} bind def
/initmaze {
0 1 height 1 sub {/row exch def
/mrow maze row get def
0 1 width 1 sub {/col exch def
% north
hor row 1 add get col get 0 eq {
mrow col 2 copy get //NORTH or put
} if
% west
vert col get row get 0 eq {
mrow col 2 copy get //WEST or put
} if
% south
hor row get col get 0 eq {
mrow col 2 copy get //SOUTH or put
} if
% east
vert col 1 add get row get 0 eq {
mrow col 2 copy get //EAST or put
} if
} for
} for
} bind def
/step {% row col side => row' col'
/side exch def
/col exch def
/row exch def
side //NORTH eq {
row 1 add col
} {
side //WEST eq {
row col 1 sub
} {
side //SOUTH eq {
row 1 sub col
} {
side //EAST eq {
row col 1 add
} {
(step: bad side ) print side ==
} ifelse
} ifelse
} ifelse
} ifelse
} bind def
/done false def
/escape {% row col => -
/col exch def
/row exch def
row mexit eq col width 1 sub eq and {
(done)==
row col
/done true store
} {
row col 2 copy mget //CRUMB or mset
row col
[//NORTH //WEST //SOUTH //EAST] {/side exch def
done {exit} if
2 copy mget /val exch def
val side and 0 ne {
2 copy side step 2 copy
mget /val exch def
val //CRUMB and 0 eq {
escape
} {
pop pop
} ifelse
} if
} forall
done not {
pop pop
} if
} ifelse
} bind def
/solve {
% close the entrance
vert 0 get mentrance 1 put
initmaze
% start the escape
/path [mentrance -1 mentrance 0 escape 2 copy 1 add] def
% draw the path
.5 setgray
.5 .5 translate
path 1 get path 0 get moveto
2 2 path length 1 sub {/i exch def
path i 1 add get path i get lineto
} for
stroke
showpage
} bind def
% eject the page
copypage solve
%%EOF

View file

@ -0,0 +1,588 @@
%!
% vasarely
% Elizabeth D. Zwicky
% zwicky@sgi.com
/vasarelysave save def % prevent residual side effects
%
% Inspired by Vasarely's experiments with tilting circles and squares
% (for instance "Tlinko" and "Betelgeuse"
%% circles
/part { circle } def /nnrand false def
%% squares
% /part { ngon } def /nn 4 def /nnrand false def
%% random polygons
% /part { ngon } def /nnrand true def
%% random stars (not my favorite on this program)
% /part { nstar } def /nnrand true def
%% tilt the base shape a random amount?
/twist false def
% /twist true def
/rainbow false def
%% To make rainbows
% /rainbow true def
%% Set this to 1 to go through a full range of colors
/rainrange .25 def
% number of different designs per page
/inheight 2 def
/inwidth 2 def
% number of repeats in a design
/xtimes 10 def
/ytimes 16 def
%% This sets the relationship between the two hues: comptwo is maximum contrast
/colorway {comptwo} def
%% monochrome comptwo harmtwo harmfour freecolor compthree closeharm
%% origcolor
%% This sets the brightness and saturation of the colors; vivid makes
%% them both bright
/colorfam {vivid} def
%% vivid jewel intense medium pastel free orig contrast
%% medjewel medvivid vivpastel medpastel
%% Only experts below this point!
10 srand
/seed rand def
/starcompensate false def
/constroke 1 def
/circle {
/radius radius 1.33 mul def
currentpoint /herey exch def /herex exch def
herex herey radius 0 360 arc
} def
/ngon{ % polygon of n sides, n determined by nn
nside 2 div radius rmoveto
nn cvi {
nside neg 0 rlineto
360 360 nn div sub neg rotate
} repeat
closepath
} def
/nstar{ % star of n points, n determined by nstarslider
/radius radius 1.33 mul def
currentpoint /herey exch def /herex exch def
0 radius rmoveto
90 nstarangle 2 div add neg rotate
nn cvi {nstarside 0 rlineto
180 180 nstarangle 2 mul sub sub neg rotate
nstarside 0 rlineto
180 180 360 nn div sub nstarangle 2 mul sub sub rotate
} repeat
90 nstarangle 2 div add rotate
closepath
} def
/nstarangle {180 360 nn div sub 3 div} def
/nstarside {
2
radius
1
180 nn div
sin
div
div
mul
nstarangle sin
mul
180
nstarangle 2 mul
sub
sin
div
} def
/nside {
2
radius
360 nn div 2 div tan
mul
mul
} def
/tan { /alpha exch def
alpha sin
1 alpha sin dup mul sub sqrt
div
} def
/pastel {
/backbright high def
/backsat medlow def
/fillbright high def
/fillsat medlow def
/eobright high def
/eosat medlow def
constroke 0 eq {
/strokebright high def
/strokesat medlow def
}
{
/strokebright low def
/strokesat high def
} ifelse
} def
/jewel {
/fillbright med def
/fillsat high def
/backbright med def
/backsat high def
/eobright med def
/eosat high def
constroke 0 eq {
/strokebright medlow def
/strokesat high def
}
{
/strokebright high def
/strokesat medlow def
} ifelse
} def
/vivid {
/fillsat 1 def
/fillbright high def
/eosat 1 def
/eobright high def
/backsat 1 def
/backbright high def
constroke 0 eq {
/strokesat 1 def
/strokebright high def
}
{
/strokesat high def
/strokebright medlow def
} ifelse
} def
/free {
/fillsat anyrand def
/fillbright anyrand def
/eosat anyrand def
/eobright anyrand def
/backsat anyrand def
/backbright anyrand def
/strokesat anyrand def
/strokebright anyrand def
} def
/contrast {
/sat medhigh def
/bright rand 2 mod 0 eq {medhigh} {medlow} ifelse def
/backsat sat def
/backbright bright def
/eosat sat def
/eobright 1 bright sub def
/fillsat sat def
/fillbright bright def
/strokebright rand 2 mod def
/strokesat rand 2 mod def
} def
/medium {
/backsat med def
/backbright med def
/eosat med def
/eobright med def
/fillsat med def
/fillbright med def
/strokebright med def
/strokesat med def
} def
/intense {
/backsat high def
/backbright med def
/eosat high def
/eobright high def
/fillsat high def
/fillbright med def
/strokebright high def
/strokesat high def
} def
/orig {
/backsat rand 99 mod 55 add 100 div def
/backbright rand 99 mod 35 add 100 div def
/eosat rand 77 mod 22 add 100 div def
/eobright 90 rand 75 mod sub 15 add 100 div def
/fillsat 100 rand 90 mod sub 100 div def
/fillbright 100 rand 45 mod sub 20 add 100 div def
/strokebright 100 rand 55 mod sub 100 div def
/strokesat 100 rand 85 mod sub 100 div def
} def
/medjewel {
/alt rand 2 mod def
/backsat alt 0 eq {high} { med} ifelse def
/fillsat alt 0 eq {med} {high} ifelse def
/eosat alt 0 eq {high} {med} ifelse def
/backbright med def
/fillbright med def
/eobright med def
constroke 0 eq {
/strokebright medlow def
/strokesat high def
}
{
/strokebright high def
/strokesat medlow def
} ifelse
} def
/medvivid {
/alt rand 2 mod def
/backsat alt 0 eq {1} { med} ifelse def
/fillsat alt 0 eq {med} {1} ifelse def
/eosat alt 0 eq {1} {med} ifelse def
/backbright alt 0 eq {high} {med} ifelse def
/eobright alt 0 eq {high} {med} ifelse def
/fillbright alt 0 eq {med} {high} ifelse def
constroke 0 eq {
/strokesat 1 def
/strokebright high def
}
{
/strokesat high def
/strokebright medlow def
} ifelse
} def
/vivpastel {
/backlight rand 2 mod def
/backsat backlight 0 eq {medlow} {1} ifelse def
/eosat backlight 0 eq {medlow} {1} ifelse def
/fillsat backlight 0 eq {1} {medlow} ifelse def
/fillbright high def
/backbright high def
/eobright high def
constroke 0 eq {
/strokesat 1 def
/strokebright high def
}
{
/strokesat high def
/strokebright medlow def
} ifelse
} def
/medpastel {
/alt rand 2 mod def
/backsat alt 0 eq {medlow} {med} ifelse def
/eosat alt 0 eq {medlow} {med} ifelse def
/fillsat alt 0 eq {med} {medlow} ifelse def
/fillbright alt 0 eq { high } {med} ifelse def
/backbright alt 0 eq {med} { high } ifelse def
/eobright alt 0 eq {med} { high } ifelse def
constroke 0 eq {
/strokebright high def
/strokesat medlow def
}
{
/strokebright low def
/strokesat high def
} ifelse
} def
/maxcon {
rand 2 mod 1 eq {
/backsat 0 def
/backbright 0 def
/eosat 0 def
/eobright 0 def
/fillsat 0 def
/fillbright 1 def
/strokebright 1 def
/strokesat 0 def
}
{
/backsat 0 def
/backbright 1 def
/eosat 0 def
/eobright 1 def
/fillsat 0 def
/fillbright 0 def
/strokebright 0 def
/strokesat 0 def
}
ifelse
} def
/monochrome {
/fillhue hue closevary def
/strokehue hue closevary def
/eohue hue closevary def
/backhue hue def
} def
/blackandwhite {
/fillhue 1 def
/eohue 0 def
/backhue 0 def
/strokehue 1 def
} def
/freecolor {
/fillhue anyrand def
/strokehue anyrand def
/eohue anyrand def
/backhue anyrand def
} def
/purple {
/fillhue rand 15 mod 80 add 100 div def
/backhue rand 15 mod 80 add 100 div def
/strokehue rand 15 mod 80 add 100 div def
/eohue rand 15 mod 80 add 100 div def
/backhue rand 15 mod 80 add 100 div def
} def
/comptwo {
/fillhue hue closevary def
/strokehue hue .5 add dup 1 gt {1 sub} if def
/backhue strokehue def
/eohue strokehue closevary def
} def
/compthree {
/backhue hue def
/strokehue hue 1 3 div add dup 1 gt {1 sub} if closevary def
/fillhue strokehue closevary def
/eohue hue 1 3 div sub dup 1 lt { 1 add} if closevary def
} def
/origcolor {
/backhue hue def
/strokehue
hue 1000 mul cvi 3 mod dup 1 eq
{hue closevary}
{2 eq
{rand 999 mod 1000 div}
{hue .5 add dup 1 gt {1 sub} if }
ifelse
}
ifelse def
/fillhue hue 1000 mul cvi 3 mod dup 1 eq
{hue closevary}
{2 eq
{rand 999 mod 1000 div}
{hue .5 add dup 1 gt {1 sub} if }
ifelse
}
ifelse
def
/eohue hue 1000 mul cvi 2 mod 1 eq
{hue closevary}
{rand 999 mod 1000 div}
ifelse def
} def
/harmtwo {
/fillhue hue closevary def
/backhue hue def
/strokehue hue .2 add dup 1 gt {1 sub} if closevary def
/eohue strokehue closevary def
} def
/harmfour {
/fillhue hue closevary def
/backhue hue .1 add dup 1 gt {1 sub} if def
/strokehue hue .2 add dup 1 gt {1 sub} if closevary def
/eohue hue .1 sub dup 1 lt {1 add} if closevary def
} def
/closeharm {
/fillhue hue def
/backhue hue .05 add dup 1 gt {1 sub} if closevary def
/strokehue hue .1 add dup 1 gt {1 sub} if closevary def
/eohue hue .05 sub dup 0 lt {1 add} if closevary def
} def
/high {100 rand 25 mod sub 100 div } def
/med { rand 33 mod 33 add 100 div } def
/medhigh {100 rand 50 mod sub 100 div } def
/medlow {rand 50 mod 100 div } def
/low { rand 25 mod 100 div} def
/anyrand { rand 100 mod 100 div } def
/closevary {rand 70 mod rand 100 mod sub 1000 div add} def
%rainbow
% {/colorfill {fillhue 1 1 sethsbcolor fill} def}
/colorfill {fillhue fillsat fillbright sethsbcolor fill } def
%ifelse
/colorstroke {strokehue strokesat strokebright sethsbcolor stroke } def
/eocolorfill {eohue eosat eobright sethsbcolor eofill } def
/backfill{ backhue backsat backbright sethsbcolor fill } def
/xstep { xrange xtimes 1 sub div x 1 sub mul } def
/ystep { yrange ytimes 1 sub div y 1 sub mul} def
/functionarray [
{sin abs}
{sin }
{cos }
{cos abs}
{sin dup mul }
{cos dup mul }
{sin abs sqrt }
{cos abs sqrt }
] def
/range { /top exch def /bottom exch def /number exch def
% number is between -1 and 1
/rangesize top bottom sub def
number 1 add 2 div
% number is now between 0 and 1
rangesize mul
bottom add
} def
/drawone {
/radius
width height lt {width 3 div} {height 3 div} ifelse
def
seed srand
0 0 moveto
/origmatrix [ 0 0 0 0 0 0 ] currentmatrix def
[ % xstep function ystep function2 add 0.4 1.3 range
1
ystep function xstep function add -0.25 0.25 range
ystep function3 xstep function2 add -0.5 0.5 range
% xstep function4 ystep function mul 0.4 1.3 range
1
0
0
]
concat
twist {twistdeg rotate} if
part colorfill
origmatrix setmatrix
rainbow
{/fillhue fillhue rainrange xtimes ytimes mul div add dup 1 gt {1 sub} if def}
if
} def
/notdrawone {
seed srand
twist {/twistdeg rand 360 mod def} if
nnrand {/nn rand 6 mod 3 add def} if
/x1 rand width 3 div cvi mod width 8 div add def
/y1 rand height 3 div cvi mod height 8 div add def
rand 3 mod dup 1 eq
{pop /x2 rand width 2 div cvi mod def
/y2 rand height 2 div cvi mod def}
{ 2 eq
{/x2 y1 def /y2 x1 def}
{/x2 y1 width mul height div def /y2 x1 height mul width div def}
ifelse
}
ifelse
/radius width height gt {width} {height} ifelse 2.5 div def
/stripe rand width 10 div cvi mod 2 add def
starcompensate { /stripe stripe 2 mul def /radius radius 10 nn div mul def } if
/i 1 def
/repeats radius stripe div cvi 1 add def
/nnincr 1 def
repeats {
colorvary {colorfam colorway} if
/i i 1 add def
/radius radius stripe sub def
} repeat
} def
/page {
clippath pathbbox /ury exch def /urx exch def /lly exch def /llx exch
def
/pagewidth urx llx sub 36 72 mul min def
/pageheight ury lly sub 36 72 mul min def
0 0 moveto
llx lly translate
/outerwidth
pagewidth inwidth div
def
/outerheight
pageheight inheight div
def
/width
outerwidth xtimes div
def
/height
outerheight ytimes div
def
/size
width height gt {width} {height} ifelse
def
inwidth {
inheight {
/seed rand def
/hue rand 999 mod 1000 div def
colorway colorfam
/x 1 def /y 1 def
nnrand {/nn rand 6 mod 3 add def} if
/twistdeg rand 360 mod def
/function functionarray rand functionarray length mod get def
/function2 functionarray rand functionarray length mod get def
/function3 functionarray rand functionarray length mod get def
/function4 functionarray rand functionarray length mod get def
/xrange [ 90 180 270 360 180 360 ] rand 6 mod get def
/yrange [ 90 180 270 360 180 360 ] rand 6 mod get def
initclip
newpath
0 0 moveto
outerwidth 0 rlineto
0 outerheight rlineto
outerwidth neg 0 rlineto
backfill
xtimes {
ytimes{
/y y 1 add def
width 2 div height 2 div translate
drawone
width 2 div neg height 2 div neg translate
0 height translate
} repeat
/y 1 def
/x x 1 add def
width height ytimes mul neg translate
} repeat
width xtimes mul neg outerheight translate
} repeat
outerwidth outerheight inheight mul neg translate
} repeat
} def
page showpage
clear cleardictstack
vasarelysave restore

File diff suppressed because it is too large Load diff