%!PS % Revised Bricks bricks4.psl % ============================================================== % Copyright c 2019 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % Linking welcome. Reposting expressly forbidden. % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % This is an extract of our ultra sneaky PostScript brick drawing routine % from our PostScript Secrets. The trick is to use the setdash operator % to simultanously write all of the bricks at once! % This also has to be my entry as the "top PostScript hack of all time" % Code can be sent to Google Drive or Acrobat Distiller. %% ////// Extracted Gonzo Utilities ////// /random {rand 65536 div 32768 div mul cvi} def %% ////// end gonzo extractions ///// % ///////// (A) WEB FRIENDLY COLOR UTILITIES ///////////// % tintmat is a self-generating list of 216 triple color values /webtintmat [ 0 1 5 { /a exch store 0 1 5 { /b exch store 0 1 5 { 5 div b 5 div a 5 div }for } for } for ] def % setwebtint accepts a color number 0 to 215 and then % sets the PostScript color generator for later use... /setwebtint { abs cvi 216 cvi mod % restrict range webtintmat exch 3 mul 3 getinterval % get values from table aload pop setrgbcolor} def % and set them % The blocks are arranged as red to the right, green % up in order of increasing blue. % Some "pure color" sequences are % red: 0 1 2 3 4 5 % orange: 0 7 8 15 16 23 (sort of) % yellow: 0 7 14 21 28 35 % green: 0 6 12 18 24 30 % aqua: 0 42 84 126 168 210 % blue: 0 36 72 108 144 180 % magenta: 0 37 74 111 148 185 % purple 0 73 73 110 147 183 (sort of) % gray 0 43 86 129 172 215 %%%%%%%%%%% excerpted perspective routines %%%%%%%%%%%% % Here are some excerpts from my perspective drawing routines % found in my PostScript Show & Tell… /px {/zz exch def /yy exch def /xx exch def yo dup yy add div dup xx xo sub mul exch zz zo sub mul} def /psave {/zh zz def /yh yy def /xh xx def} def /pm {px psave moveto} def /prm {/zi exch def /yi exch def /xi exch def objrot cos xi mul objrot sin yi mul sub xh add objrot sin xi mul objrot cos yi mul add yh add zi zh add px moveto psave} def /prd {/zi exch def /yi exch def /xi exch def objrot cos xi mul objrot sin yi mul sub xh add objrot sin xi mul objrot cos yi mul add yh add zi zh add px lineto psave} def /xrd {0 0 prd} def /yrd {0 exch 0 prd} def /zrd {0 exch 0 exch prd} def /zrm {0 exch 0 exch prm} def /xzrect {/zdis exch def /xdis exch def save zdis zrd xdis xrd zdis neg zrd closepath gsave brickcolor setwebtint fill grestore stroke restore} def /yzrect {/zdis exch def /ydis exch def save zdis zrd ydis yrd zdis neg zrd closepath gsave brickcolor setwebtint fill grestore stroke restore} def /xyrect {/ydis exch def /xdis exch def save ydis yrd xdis xrd ydis neg yrd closepath gsave brickcolor setwebtint fill grestore stroke restore} def /pbox {/zdis exch def /ydis exch def /xdis exch def save xdis zdis xzrect restore save ydis zdis yzrect restore save zdis zrm xdis ydis xyrect restore } def % And here are two of the magic brick routines. The setdash operator (!) % is set on the fly to one brick high in the perspective space… /xzbrickwall {gsave /zbri exch def /xbri exch def xbri brickwide mul 0 0 prm 0 1 zbri 1 sub cvi {gsave pop xbri brickwide mul neg 0 brickhi prm xbri brickwide mul 0 0 prd stroke grestore} for xbri brickwide neg mul 0 0 prm 0 1 xbri 1 sub cvi {gsave pop brickwide 0 zbri brickhi mul neg prm currentpoint exch pop /cph exch def 0 0 zbri brickhi mul prd cph currentpoint exch pop sub abs zbri div mark exch ] 0 setdash stroke grestore} for xbri brickwide neg mul 0 0 prm 0 1 xbri 1 sub cvi {gsave pop brickwide 0 zbri brickhi mul neg prm currentpoint exch pop /cph exch def 0 0 zbri brickhi mul prd cph currentpoint exch pop sub abs zbri div dup mark exch ] exch 0.2 setlinewidth setdash stroke grestore } for} def /yzbrickwall { gsave /zbri exch def /ybri exch def 0 ybri brickwide mul 0 prm 0 1 zbri 1 sub cvi {gsave pop 0 ybri brickwide mul neg brickhi prm 0 ybri brickwide mul 0 prd stroke grestore} for 0 ybri brickwide neg mul 0 prm 0 1 ybri 1 sub cvi {gsave pop 0 brickwide zbri brickhi mul neg prm currentpoint exch pop /cph exch def 0 0 zbri brickhi mul prd cph currentpoint exch pop sub abs zbri div dup mark exch ] exch setdash stroke grestore } for 0 ybri brickwide neg mul 0 prm 0 1 ybri 1 sub cvi {gsave pop 0 brickwide zbri brickhi mul neg prm currentpoint exch pop /cph exch def 0 0 zbri brickhi mul prd cph currentpoint exch pop sub abs zbri div mark exch ] 0 setdash stroke grestore } for} def %%%%%%%%% bricks code starts here %%%%%%%%%%%%% 0 setwebtint % black lines 140 710 translate 1 setlinecap 1 setlinejoin 1 setlinewidth /xo 00 def /yo 700 def /zo 250 def /objrot 45 def /brickhi 5 def /brickwide 16 def /numbricksx 10.5 def /numbricksy 2.5 def /numbricksz 12.5 def /bldz numbricksz brickhi mul def /bldx numbricksx brickwide mul def /bldy numbricksy brickwide mul def /brickcolor 89 store % as needed by setwebtint 0 0 0 pm bldx bldy bldz pbox 0 0 0 pm numbricksx numbricksz 1.5 sub xzbrickwall 0 0 0 pm numbricksy numbricksz 1.5 sub yzbrickwall % overlay needed for different top color /brickcolor 172 store % /currentshade 0.2 def 0 0 brickhi 11 mul pm bldx bldy brickhi 1.5 mul pbox showpage % EOF