%!PS %%Creator: jms %%Title: varenbeuk blad %%EndComments % Batch calls use -dREAL. % systemdict /REAL known { /debug false def /onscreen false def } { /debug false def % /debug true def /onscreen debug def /onscreen true def %/onscreen false def } ifelse % Make each differ % %1 srand realtime srand % Lib functions. % /xdef {exch def} bind def /sqr {dup mul} bind def /mm {25.4 div 72 mul} bind def /imm {25.4 mul 72 div} bind def /cm {2.54 div 72 mul} bind def /icm {2.54 mul 72 div} bind def /max {2 copy gt {exch} if} bind def /min {2 copy lt {exch} if} bind def /inc {dup cvx exec 1 add def} bind def /dec {dup cvx exec 1 sub def} bind def /mmod {dup 0 eq {exch pop}{mod} ifelse} bind def % Shrinking correction. % debug not { 1 .96 div 1 .92 div scale 2 3 translate } if % Debug to see on screen. % onscreen { 1 cm 2 cm translate .2 % .06 dup scale /vl 1 def /vls 1 def } if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% (\n bi ) print systemdict /LAKEN known { % -dLAKEN is used. /blocksize 35 cm def (Laken ) print /NumLeafs 2000 def /ShowInitial false def /PointSize 225 def /NumSideLeafs NumLeafs 3 div def /NumCornerLeafs 40 def /radius 6 cm def /vl 15 def % Search step size. /vls vl 1 mul def % Search step size. % Size of cloth % /maxx 163 cm def /maxy 448 cm def /llx 2 cm def /lly 12 cm def /urx maxx llx sub def /ury maxy lly sub def % Leafs are between 8 and 6 cm % LeafScale can change that. % /LeafScale 1 def /filldx 12 cm def /filldy 12 cm def } if systemdict /GRAP known { % -dGRAP is used. /blocksize 35 cm def (Grap ) print /NumLeafs 812 def /ShowInitial false def /PointSize 225 def /NumSideLeafs NumLeafs 3 div def /NumCornerLeafs 40 def /radius 6 cm def /vl 15 def % Search step size. /vls vl 1 mul def % Search step size. % Size of cloth % /maxx 163 cm def /maxy 163 cm def /llx 11.5 cm def /lly 11.5 cm def /urx maxx llx sub def /ury maxy lly sub def % Leafs are between 8 and 6 cm % LeafScale can change that. % /LeafScale 1 def /filldx 12 cm def /filldy 12 cm def } if systemdict /SERVET78 known { % -dSERVET78 is used. /blocksize 10 cm def (Servet 78 ) print % Show Initial if -dInitial=X. % /ShowInitial systemdict /Initial known def /NumLeafs 555 def /PointSize 225 def /NumSideLeafs NumLeafs 3 div def /NumCornerLeafs 40 def /radius 6 cm def /vl 28 def % Search step size. /vls vl 1 mul def % Search step size. % Size of cloth % /maxx 81 cm def /maxy 81 cm def /llx 5.83 cm def /lly 5.83 cm def /urx maxx llx sub def /ury maxy lly sub def % Leafs are between 8 and 6 cm % LeafScale can change that. % /LeafScale 78 140 div def /filldx 16 cm def /filldy 16 cm def } if systemdict /SERVET59 known { % -dSERVET59 is used. /blocksize 10 cm def (Servet 59) print % Show Initial if -dInitial=X. % /ShowInitial systemdict /Initial known def /NumLeafs 530 def /PointSize 180 def /NumSideLeafs NumLeafs 3 div def /NumCornerLeafs 40 def /radius 5 cm def /vl 23 def % Search step size. /vls vl 1 mul def % Search step size. % Size of cloth % /maxx 62 cm def /maxy 62 cm def /llx 5.14 cm def /lly 5.14 cm def /urx maxx llx sub def /ury maxy lly sub def % Leafs are between 8 and 6 cm % LeafScale can change that. % /LeafScale 59 140 div def /filldx 12 cm def /filldy 12 cm def } if systemdict /STROOK known systemdict /REAL known not or { % -dSTROOK is used. /blocksize 10 cm def (Stroke ) print % Show Initial if -dInitial=X. % /ShowInitial systemdict /Initial known def /NumLeafs 200 def /PointSize 64 def /NumSideLeafs NumLeafs 3 div def /NumCornerLeafs 40 def /radius 5 cm def /vl 23 def % Search step size. /vls vl 1 mul def % Search step size. % Size of cloth % /maxx 13 cm def /maxy 448 cm def /llx 1.5 cm def /lly 1.5 cm def /urx maxx llx sub def /ury maxy lly sub def % Leafs are between 8 and 6 cm % LeafScale can change that. % /LeafScale 59 140 div def /filldx 12 cm def /filldy 12 cm def } if ([) print NumLeafs 200 string cvs print (] ) print ShowInitial { (') print Initial print (' ) print } if debug { (DEBUG ) print } if onscreen { (ONSCREEN ) print } if (\n) print flush %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Save current ctm % /ctm matrix currentmatrix def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % x y DotShow - % /DotShow { gsave newpath 1 mm add moveto 1 mm 0 360 arc .1 mm setlinewidth stroke grestore } bind def % [[x y] [x y] [x y] ... ] aDotShow - % /aDotShow { { aload pop DotShow } forall } bind def % x y d hlineto - % /hlineto { 3 1 roll % d Ex Ey currentpoint % d Ex Ey Bx By 4 copy 3 2 roll % .... Ex Bx By Ey add 2 div % .... Ex Bx My 3 1 roll % .... My Ex Bx add 2 div % d Ex Ey Bx By My Mx 3 index exch sub % d Ex Ey Bx By My Vx exch 2 index % d Ex Ey Bx By Vx My By sub % d Ex Ey Bx By Vx -Vy 7 6 roll exch % Ex Ey Bx By Vx d -Vy 1 index % Ex Ey Bx By Vx d -Vy d div 3 1 roll % Ex Ey Bx By -Vy/d Vx d div % Ex Ey Bx By -Vy/d Vx/d 2 copy 6 4 roll % Ex Ey Nx Ny Nx Ny Bx By 3 2 roll % Ex Ey Nx Ny Nx Bx By Ny add 3 1 roll % Ex Ey Nx Ny Cy Bx By add exch % Ex Ey Nx Ny Cx Cy 4 2 roll % Ex Ey Cx Cy Nx Ny 5 index 5 index % Ex Ey Cx Cy Nx Ny Ex Ey 3 2 roll add % Ex Ey Cx Cy Nx Ex Fy 3 1 roll add % Ex Ey Cx Cy Fy Fx exch % Ex Ey Cx Cy Fx Fy 4 copy % ... Cx Cy Fx Fy .3 mul exch .3 mul % ... Cx Cy .3Fy .3Fx 4 2 roll % ... .3Fy .3Fx Cx Cy .7 mul exch .7 mul % ... .3Fy .3Fx .7Cy .7Cx 3 2 roll add % ... .3Fy .7Cy Dx 3 1 roll add % Ex Ey Cx Cy Fx Fy Dx Dy 6 2 roll % Ex Ey Dx Dy Cx Cy Fx Fy 3 2 roll % Ex Ey Dx Dy Cx Fx Fy Cy .1 mul exch .9 mul add % Ex Ey Dx Dy Cx Fx Gy 3 1 roll % Ex Ey Dx Dy Gy Cx Fx .9 mul exch .1 mul add exch % Ex Ey Dx Dy Gx Gy 6 4 roll % Dx Dy Gx Gy Ex Ey curveto } bind def % [x y] r aRandXY [x' y'] % /aRandXY { floor cvi exch aload pop % r x y 2 index dup % r x y r r rand exch 2 mul 1 add % r x y r ? 2r+1 mod % r x y r 0?2r sub % r x y -r?r add % r x y' 3 1 roll exch dup % y' x r r rand exch 2 mul 1 add % y' x r ? 2r+1 mod sub add exch % x' y' [ 3 1 roll ] % [x' y'] } bind def % Ax Ay Bx By Cx Cy CircleCenter Dx Dy Dr % Calculate the center and radius % of a circle going trough a b and c. % /CircleCenter { save 7 1 roll /Cy xdef /Cx xdef /By xdef /Bx xdef /Ay xdef /Ax xdef % DEBUG: Show points % %Ax Ay DotShow %Bx By DotShow %Cx Cy DotShow % Calc center. % /ABa Bx Ax sub By Ay sub div neg def /ABx Bx Ax add 2 div def /ABy Ay By add 2 div def /ABb ABy ABa ABx mul sub def /BCa Cx Bx sub Cy By sub div neg def /BCx Cx Bx add 2 div def /BCy By Cy add 2 div def /BCb BCy BCa BCx mul sub def % Dx BCb ABb sub ABa BCa sub div % Dy ABa 1 index mul ABb add % Dr 1 index Ax sub sqr 1 index Ay sub sqr add sqrt 4 3 roll restore } bind def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % seed bool Leaf - % seed bool Leaf upath % % If bool is true, and outline upath % is returned, other wise the Leaf is % painted. % /Leaf { gsave /OutlineOnly xdef srand % Seed the random % Pick random length between 6 and 8 cm % Pick random bend between 0 and 1 cm % /LeafLength rand 200 mod 100 div 6 add cm def /TopSway rand 501 mod 100 div 2.5 sub mm def /nPoints 3 def % Show two halfs... % 1 1 2 { dup 2 eq /SecondHalf xdef -1 1 scale /TopSway TopSway -1 mul def % Make circle through (0,0) (0,ll) (ll/2,ll) % plus some random. % 0 0 TopSway LeafLength LeafLength rand 200 mod 100 div .3 sub cm add LeafLength 2 div CircleCenter /Dr xdef /Dy xdef /Dx xdef % DEBUG: Show circle % %gsave % Dx Dr add Dy moveto % Dx Dy Dr 0 360 arc % 0 setlinewidth % [1 5] 0 setdash % stroke %grestore % Differ 1 or 0 sinds last time. % Don't do 0 difference often. % Don't go below 3 or above 5. % Don't make 5 happen very often. % /change rand 3 mod 1 sub dup 0 eq rand 100 mod 80 lt and { pop rand 2 mod 2 mul 1 sub } if def /nPoints nPoints change add dup 3 lt {pop 4} if dup 5 gt {pop 3} if dup 5 eq rand 100 mod 90 lt and {pop 3} if def /StemLength rand 6 mod 100 div 0.15 add def /MidLength rand 6 mod 100 div 0.45 add def /EndLength StemLength MidLength add def /aPoints [ LeafLength StemLength mul LeafLength MidLength mul nPoints 1 add div LeafLength EndLength mul 0.01 add { [ exch % ... [ y dup Dy sub sqr Dr sqr exch sub sqrt neg Dx add exch % ... [ x y ] .5 mm aRandXY } for nPoints 3 gt rand 100 mod 10 lt and { % lower x of last point. aload pop exch rand 200 mod 100 div 1 add div exch % upper Y rand 200 mod 100 div 1 add mm add [ 3 1 roll ] } if ] def % Now we [[x1 y1] [x2 y2] ... ] in aPoints % Let's creat aKeeps % /Ka aPoints 0 get aload pop % ... x1 y1 LeafLength sub exch % ... dy x1 div def /Kb LeafLength def /aKeeps [ aPoints { [ exch aload pop exch pop % ... y rand 200 mod 100 div 2 add mm sub dup % y y Kb sub Ka div % y x rand 150 mod 100 div .3 add mm add exch % x y ] } forall ] def % /aKeeps contains points to Keeps. %TopSway LeafLength DotShow %0 LeafLength DotShow %aPoints aDotShow %aKeeps aDotShow % Outline the Leaf gsave newpath 0 setgray 0 0 moveto 0 LeafLength 4 div 2 copy TopSway 2 div LeafLength 2 div curveto [] 0 setdash 1.2 mm setlinewidth OutlineOnly { strokepath /pipo true upath def } { stroke } ifelse grestore% OutlineOnly { /pipo load uappend } if 0 LeafLength StemLength 2 div mul moveto 2 1 nPoints 1 add { dup aPoints exch get aload pop 1.2 sub exch 1.2 sub exch rand 2 mod 2 mul 1 sub 7 add hlineto dup aPoints exch get aload pop 1.2 sqr 2 mul sqrt 200 120 arcn aKeeps exch get aload pop -3 rand 400 mod 100 div sub hlineto } for TopSway LeafLength -8 rand 4 mod sub hlineto % Overscan with white. % %gsave % 1 setgray % .6 mm setlinewidth % [3 1 2 1 7 1 5 1] 0 setdash % stroke %grestore closepath OutlineOnly { % Add to LeafPath % SecondHalf { /LeafPath true upath def newpath } if } { 0 setgray fill } ifelse % Nervs. % gsave .2 mm setlinewidth 1 setgray 2 1 nPoints 1 add { dup 1 sub aKeeps exch get aload pop exch pop 0 exch % 0 y rand 100 mod 100 div 1 add mm sub moveto aPoints exch get aload pop .3 mm sub exch .3 mm add exch rand 2 mod 2 mul 1 sub 7.5 add hlineto [ rand 6 mod 1 add rand 3 mod 1 add rand 6 mod 1 add rand 3 mod 1 add rand 6 mod 1 add rand 3 mod 1 add rand 6 mod 1 add rand 3 mod 1 add rand 6 mod 1 add rand 3 mod 1 add ] 0 setdash OutlineOnly { newpath } { stroke } ifelse } for %0 LeafLength -8 hlineto % Main Nerve. % 0 .6 mm moveto 0 LeafLength .4 mul 2 copy TopSway LeafLength 1 mm sub curveto .2 mm setlinewidth [ rand 6 mod 1 add rand 4 mod 1 add rand 6 mod 1 add rand 4 mod 1 add rand 6 mod 1 add rand 4 mod 1 add rand 6 mod 1 add rand 4 mod 1 add rand 4 mod 1 add rand 6 mod 1 add ] 0 setdash OutlineOnly { newpath } { stroke } ifelse grestore pop } for OutlineOnly { /LeafPath load } if % return arg grestore } bind def % x0 y0 x1 y1 boxto - % /boxto { 3 index 3 index moveto 3 index 1 index lineto 1 index 1 index lineto 1 index 3 index lineto 3 index 3 index lineto 4 { pop } repeat } bind def % Make array for bbox upath % cutting up the sheet. % /bNx maxx blocksize div cvi 1 add def /bNy maxy blocksize div cvi 1 add def % Make array's for bbox % /bAa bNx 1 add array def /uAa bNx 1 add array def 1 1 bNx { dup bAa exch bNy 1 add array put uAa exch bNy 1 add array % [] 1 1 bNy { 1 index exch % [] [] j NumLeafs % bNy bNx mul 10 div div cvi % [] [] j n array dup 0 0 put % [] [] [0...] put % [] } for put } for % Now we kan use % bAa i get j get % % i j [] bGet val % /buGet { 3 2 roll get exch get } bind def % i j val bPut % % /buPut { 4 3 roll get % j val [] 3 1 roll % [] j val put } bind def /bGet { bAa buGet } bind def /bPut { bAa buPut } bind def /uGet { uAa buGet } bind def /uPut { uAa buPut } bind def bNx 200 string cvs print (,) print bNy 200 string cvs print (\n) print flush % Fill bbox arrayarray. % 1 1 bNx { 1 1 bNy { % i j onstack newpath 2 {1 index 1 sub blocksize mul} repeat 2 {3 index blocksize mul} repeat boxto debug { gsave 0 1 1 setrgbcolor stroke grestore} if 2 copy false upath bPut pop } for pop } for % Now bAa [[]] is filled with bbox upaths. % Array stuff for userpaths. % /aUpath NumLeafs 10 add array def /nUpath 0 def /aUpathAdd { [ exch % [ upath matrix currentmatrix ] % [ upath ctm ] dup aUpath nUpath 3 2 roll put /nUpath inc NumLeafs 10 add nUpath lt { (PANIC ARRAY FULL\n) print flush stop } if % Put in uAa for each infill bAa % gsave newpath % [up ctm] dup 0 get uappend % debug { gsave 1 .5 .5 setrgbcolor fill grestore } if 1 1 bNx { 1 1 bNy { % [] i j 2 copy bGet % [] i j uPath gsave ctm setmatrix infill { % debug { 2 copy bGet gsave uappend 1 .5 .5 setrgbcolor stroke grestore } if 3 copy % [] i j x i j uGet % ...x [n] dup % ...x [n] [n] 0 get 1 add % ...x [n] N 2 copy % ...x [n] N [n] N 0 exch put % ...x [N] N 3 2 roll % ...[N] N x put % [] i j [Nx] } if grestore pop } for pop } for pop grestore } bind def % upath aInfill bool % /aInfill { gsave newpath uappend false % assume no 0 1 nUpath 1 sub { aUpath exch get % [ upath ctm ] aload pop setmatrix debug{ gsave newpath dup uappend 1 0 rand 500 mod 1000 div .5 add setrgbcolor fill grestore}if infill { pop true exit } if } for grestore } bind def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % upath r g b DebugUpathFill upath % /DebugUpathFill { debug { gsave newpath setrgbcolor dup uappend fill grestore } { 3 {pop} repeat }ifelse } bind def /pSearch 0 def /pShift 0 def % startx starty ctm dx dy shiftin bool % % Go look for non collision. Return % true if succes other wise false. % /shiftin { /dy xdef /dx xdef setmatrix translate rand 360 mod rotate LeafScale dup scale % Get a leaf outline... gsave newpath rrand dup true Leaf grestore debug {gsave newpath dup uappend 1 0 0 setrgbcolor 1 setlinewidth stroke grestore } if % Loop untill leaf is outside the box or % collison is detected. { % Check if we are outside the box % 0 0 transform devmaxx devmaxy % cx cy mx my 3 2 roll lt % cx mx b 3 1 roll gt or % b 0 0 transform devminx devminy % cx cy mx my 3 2 roll gt % cx mx b 3 1 roll lt or % b or { 1 1 0 DebugUpathFill pop pop false exit } if /pRealtime realtime def % % On stack: ... srand upath % % Find if there are no % % colliding bounding box. % % % gsave % newpath % 0 0 1 DebugUpathFill % dup uappend % true % srand upath true % 0 1 nUpath 1 sub % { % aUpath exch get dup % %... true [up m] [up m] % aload pop setmatrix % infill % { % exch pop % false % exit % } % if % pop % Kill the [up m] array. % } % for % grestore % % % On stack: ... srand upath % % Find if there are no % % colliding bounding box. % % gsave newpath % 0 0 1 DebugUpathFill dup uappend /nh true def % srand upath 1 1 bNx { 1 1 bNy { % srand up T i j 2 copy bGet % srand up T i j up ctm setmatrix infill { debug { 2 copy bGet gsave newpath uappend 0 0 1 setrgbcolor stroke grestore } if % sr up T i j % bbox i j has hits. 2 copy uGet /cA xdef % sr up i j 1 1 cA 0 get { % onstack sr up i j i cA exch get % sr up i j [up ctm] dup aload pop setmatrix infill { /uA xdef % save [up ctm] /nh false def exit } { pop % Ridd the [up ctm]. } ifelse } for } if pop nh not { exit } if } for pop nh not { exit } if } for grestore /pSearch pSearch realtime add pRealtime sub def % On stack: ... srand upath true % Or : ... srand upath [upath2 ctm2] false % Given the ctm2, upath2 and upath collide. % If notthing collides, we are free to % put the leaf here! % nh { aUpathAdd % Add this leaf to the list. gsave % ... srand newpath false Leaf % Draw the leaf. grestore true % ... true exit } if uA % On stack: ... srand upath [upath2 ctm2] /pRealtime realtime def /f 16 def /oHit true def /hit true def /goup 2 def % Loop untill upath and upath2 % do not collide. % Use forward/backward binary-search. % /tmpctm matrix currentmatrix def newpath aload pop setmatrix 0 0 1 DebugUpathFill uappend tmpctm setmatrix { %debug { (f = ) print f 200 string cvs print (\n) print flush } if dx f mul dy f mul idtransform translate dup 1 0 1 DebugUpathFill infill /hit xdef hit oHit xor { /goup .5 def /f f neg def } if f abs 1 le { hit { /goup 1 def } { % debug { 1 index 0 1 0 DebugUpathFill pop copypage } if exit } ifelse } if /f f goup mul def /oHit hit def } loop % On stack: ... srand upath /pShift pShift realtime add pRealtime sub def } loop } bind def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% newpath % Draw borders and add to aUpath. % 0 0 moveto 0 maxy lineto maxx maxy lineto maxx 0 lineto llx 0 lineto llx lly lineto urx lly lineto urx ury lineto llx ury lineto llx 0 lineto closepath true upath aUpathAdd % Draw bounding box 6 pixels wide. % newpath 0 0 moveto 0 maxy lineto maxx maxy lineto maxx 0 lineto closepath 0 setgray 2 mm setlinewidth stroke % Draw seam measures. % /seem 1.5 cm def newpath 0 seem moveto seem 0 rlineto maxx seem moveto seem neg 0 rlineto maxx maxy seem sub moveto seem neg 0 rlineto 0 maxy seem sub moveto seem 0 rlineto 2 mm setlinewidth seem 0 moveto 0 seem rlineto maxx seem sub 0 moveto 0 seem rlineto seem maxy moveto 0 seem neg rlineto maxx seem sub maxy moveto 0 seem neg rlineto stroke debug { % Show border. llx lly moveto llx ury lineto urx ury lineto urx lly lineto llx lly lineto 1 mm setlinewidth 1 0 0 setrgbcolor stroke seem seem moveto seem maxy seem sub lineto maxx seem sub maxy seem sub lineto maxx seem sub seem lineto seem seem lineto 0 1 0 setrgbcolor stroke } if systemdict /STROOK known systemdict /REAL known not or { systemdict /Initial known not { /Initial (2002) def } if (TimesNewRomanPS-BoldMT) PointSize selectfont -90 rotate lly neg llx moveto -33.5 cm 2 cm rmoveto Initial stringwidth pop (year is ) print dup icm 200 string cvs print ( cm lang\n) print flush neg 0 rmoveto 0 setgray Initial show showpage quit } if ShowInitial { % Circle in the middle for initial % maxx 2 div maxy 2 div 2 copy exch radius 1.2 mul add exch moveto radius 1.2 mul 0 360 arc closepath true upath aUpathAdd newpath maxx 2 div maxy 2 div 2 copy exch radius add exch moveto radius 0 360 arc closepath 0 setgray fill newpath % Set Initial. % gsave (TimesNewRomanPS-BoldMT) PointSize selectfont newpath 0 0 moveto Initial dup true charpath pathbbox newpath 3 2 roll exch add -2 div 3 1 roll add -2 div exch maxx 2 div maxy 2 div moveto 2 {0.99 mul exch} repeat % optical correct rmoveto 1 setgray true charpath fill grestore } if % Get device maxima. % maxx 5 mm sub maxy 5 mm sub transform 5 mm 5 mm transform % x y x y 3 2 roll max /devmaxy xdef /devminy xdef max /devmaxx xdef /devminx xdef /totaleafs 0 def /totalmiss 0 def /str 200 string def /what 0 def /dodef false def % Draw Leafs around the Initial. % ShowInitial { % First accent the cirle. % 1 3.5 370 { urx llx add 2 div ury lly add 2 div ctm 4 3 roll dup cos vl mul exch sin vl mul % Shift the leaf into the bbox. % shiftin { /totaleafs inc totaleafs NumLeafs ge {exit} if } { /totalmiss inc totalmiss totaleafs 2 mul gt totalmiss 100 gt and { (TO MANY MISSES!\n) print exit } if } ifelse (\r) print totaleafs str cvs print (/) print totalmiss str cvs print flush } for } if /fillx llx filldx add def /filly lly filldy add def /nfill urx llx sub filldx div ury lly sub filldy div mul def % Now draw Leafs at random % { /what what 1 add 6 mod def what 0 eq what 1 eq NumSideLeafs 0 le and or what 2 ge what 5 le and NumCornerLeafs 0 le and or { filly ury ge totaleafs nfill add NumLeafs lt or { % Pick a random place to start. % rand urx llx sub 1000 mul cvi mod 1000 div llx add rand ury lly sub 1000 mul cvi mod 1000 div lly add } { % After a while start filling. % fillx filly debug { 2 copy exch icm cvi 200 string cvs print (,) print icm cvi 200 string cvs print (\n) print flush } if /fillx fillx filldx add def fillx urx ge { /fillx 0 def /filly filly filldy add def } if } ifelse ctm rand vls 2000 mul 1 add mod 1000 div vls sub vls sqr 1 index sqr sub sqrt rand 100 mod 50 ge {neg} if } if what 1 eq NumSideLeafs 0 gt and { % Pick random pos along the border to start. % 0 rand % 0 rand urx llx sub % 0 rand lx ury lly sub % 0 rand lx ly add 2 mul % 0 rand len 1000 mul 1 add % 0 rand 1000.len+1 cvi mod 1000 div % 0 0/len ury lly sub sub % 0 0/len-ly dup 0 gt % 0 0/len-ly bool {exch 1 add exch} if % 0/1 0/len-ly urx llx sub sub % 0 0/len-ly-lx dup 0 gt % 0 0/len-ly-lx bool {exch 1 add exch} if % 0/2 0/len-ly-lx ury lly sub sub % 0 0/len-ly-lx-ly dup 0 gt % 0 0/len-ly bool {exch 1 add exch} if % 0/3 0/len-ly pop % column num onstack [lly ury lly lly] 1 index get 1000 mul cvi rand [ury ury ury lly] 3 index get 1000 mul cvi [llx llx urx llx] 4 index get 1000 mul cvi rand [llx urx urx urx] 6 index get 1000 mul cvi % ly r uy lx r ux 2 index sub mmod add 1000 div 4 1 roll 2 index sub mmod add 1000 div % rx ry 3 2 roll % column back ctm exch [vl 0 vl neg 0] 1 index get [0 vl 0 vl neg] 3 2 roll get /NumSideLeafs dec } if what 2 eq NumCornerLeafs 0 gt and { llx ury ctm rand vl 1000 mul 1 add mod 1000 div vl sqr 1 index sqr sub sqrt /NumCornerLeafs dec } if what 3 eq NumCornerLeafs 0 gt and { urx lly ctm rand vl 1000 mul 1 add mod 1000 div neg vl sqr 1 index sqr sub sqrt neg /NumCornerLeafs dec } if what 4 eq NumCornerLeafs 0 gt and { llx lly ctm rand vl 1000 mul 1 add mod 1000 div vl sqr 1 index sqr sub sqrt neg /NumCornerLeafs dec } if what 5 eq NumCornerLeafs 0 gt and { urx ury ctm rand vl 1000 mul 1 add mod 1000 div neg vl sqr 1 index sqr sub sqrt /NumCornerLeafs dec } if % Shift the leaf into the bbox. % shiftin { /totaleafs inc totaleafs NumLeafs ge {exit} if } { /totalmiss inc totalmiss totaleafs 2 mul gt totalmiss 100 gt and { (TO MANY MISSES!\n) print exit } if } ifelse (\r) print totaleafs str cvs print (/) print totalmiss str cvs print ( ) print pSearch usertime 1 add div 100 mul cvi 200 string cvs print (% ) print pShift usertime 1 add div 100 mul cvi 200 string cvs print (% ) print flush } loop newpath % Give max fill uAa % 0 1 1 bNx { % m i 1 1 bNy { 2 copy uGet 0 get % max i j n exch pop % max i n 3 2 roll % i n max min pop exch % m i } for } for (max fill == ) print 200 string cvs print (\n) print flush showpage quit