vasarely.ps 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. %!
  2. % vasarely
  3. % Elizabeth D. Zwicky
  4. % zwicky@sgi.com
  5. /vasarelysave save def % prevent residual side effects
  6. %
  7. % Inspired by Vasarely's experiments with tilting circles and squares
  8. % (for instance "Tlinko" and "Betelgeuse"
  9. %% circles
  10. /part { circle } def /nnrand false def
  11. %% squares
  12. % /part { ngon } def /nn 4 def /nnrand false def
  13. %% random polygons
  14. % /part { ngon } def /nnrand true def
  15. %% random stars (not my favorite on this program)
  16. % /part { nstar } def /nnrand true def
  17. %% tilt the base shape a random amount?
  18. /twist false def
  19. % /twist true def
  20. /rainbow false def
  21. %% To make rainbows
  22. % /rainbow true def
  23. %% Set this to 1 to go through a full range of colors
  24. /rainrange .25 def
  25. % number of different designs per page
  26. /inheight 2 def
  27. /inwidth 2 def
  28. % number of repeats in a design
  29. /xtimes 10 def
  30. /ytimes 16 def
  31. %% This sets the relationship between the two hues: comptwo is maximum contrast
  32. /colorway {comptwo} def
  33. %% monochrome comptwo harmtwo harmfour freecolor compthree closeharm
  34. %% origcolor
  35. %% This sets the brightness and saturation of the colors; vivid makes
  36. %% them both bright
  37. /colorfam {vivid} def
  38. %% vivid jewel intense medium pastel free orig contrast
  39. %% medjewel medvivid vivpastel medpastel
  40. %% Only experts below this point!
  41. usertime srand
  42. /seed rand def
  43. /starcompensate false def
  44. /constroke 1 def
  45. /circle {
  46. /radius radius 1.33 mul def
  47. currentpoint /herey exch def /herex exch def
  48. herex herey radius 0 360 arc
  49. } def
  50. /ngon{ % polygon of n sides, n determined by nn
  51. nside 2 div radius rmoveto
  52. nn cvi {
  53. nside neg 0 rlineto
  54. 360 360 nn div sub neg rotate
  55. } repeat
  56. closepath
  57. } def
  58. /nstar{ % star of n points, n determined by nstarslider
  59. /radius radius 1.33 mul def
  60. currentpoint /herey exch def /herex exch def
  61. 0 radius rmoveto
  62. 90 nstarangle 2 div add neg rotate
  63. nn cvi {nstarside 0 rlineto
  64. 180 180 nstarangle 2 mul sub sub neg rotate
  65. nstarside 0 rlineto
  66. 180 180 360 nn div sub nstarangle 2 mul sub sub rotate
  67. } repeat
  68. 90 nstarangle 2 div add rotate
  69. closepath
  70. } def
  71. /nstarangle {180 360 nn div sub 3 div} def
  72. /nstarside {
  73. 2
  74. radius
  75. 1
  76. 180 nn div
  77. sin
  78. div
  79. div
  80. mul
  81. nstarangle sin
  82. mul
  83. 180
  84. nstarangle 2 mul
  85. sub
  86. sin
  87. div
  88. } def
  89. /nside {
  90. 2
  91. radius
  92. 360 nn div 2 div tan
  93. mul
  94. mul
  95. } def
  96. /tan { /alpha exch def
  97. alpha sin
  98. 1 alpha sin dup mul sub sqrt
  99. div
  100. } def
  101. /pastel {
  102. /backbright high def
  103. /backsat medlow def
  104. /fillbright high def
  105. /fillsat medlow def
  106. /eobright high def
  107. /eosat medlow def
  108. constroke 0 eq {
  109. /strokebright high def
  110. /strokesat medlow def
  111. }
  112. {
  113. /strokebright low def
  114. /strokesat high def
  115. } ifelse
  116. } def
  117. /jewel {
  118. /fillbright med def
  119. /fillsat high def
  120. /backbright med def
  121. /backsat high def
  122. /eobright med def
  123. /eosat high def
  124. constroke 0 eq {
  125. /strokebright medlow def
  126. /strokesat high def
  127. }
  128. {
  129. /strokebright high def
  130. /strokesat medlow def
  131. } ifelse
  132. } def
  133. /vivid {
  134. /fillsat 1 def
  135. /fillbright high def
  136. /eosat 1 def
  137. /eobright high def
  138. /backsat 1 def
  139. /backbright high def
  140. constroke 0 eq {
  141. /strokesat 1 def
  142. /strokebright high def
  143. }
  144. {
  145. /strokesat high def
  146. /strokebright medlow def
  147. } ifelse
  148. } def
  149. /free {
  150. /fillsat anyrand def
  151. /fillbright anyrand def
  152. /eosat anyrand def
  153. /eobright anyrand def
  154. /backsat anyrand def
  155. /backbright anyrand def
  156. /strokesat anyrand def
  157. /strokebright anyrand def
  158. } def
  159. /contrast {
  160. /sat medhigh def
  161. /bright rand 2 mod 0 eq {medhigh} {medlow} ifelse def
  162. /backsat sat def
  163. /backbright bright def
  164. /eosat sat def
  165. /eobright 1 bright sub def
  166. /fillsat sat def
  167. /fillbright bright def
  168. /strokebright rand 2 mod def
  169. /strokesat rand 2 mod def
  170. } def
  171. /medium {
  172. /backsat med def
  173. /backbright med def
  174. /eosat med def
  175. /eobright med def
  176. /fillsat med def
  177. /fillbright med def
  178. /strokebright med def
  179. /strokesat med def
  180. } def
  181. /intense {
  182. /backsat high def
  183. /backbright med def
  184. /eosat high def
  185. /eobright high def
  186. /fillsat high def
  187. /fillbright med def
  188. /strokebright high def
  189. /strokesat high def
  190. } def
  191. /orig {
  192. /backsat rand 99 mod 55 add 100 div def
  193. /backbright rand 99 mod 35 add 100 div def
  194. /eosat rand 77 mod 22 add 100 div def
  195. /eobright 90 rand 75 mod sub 15 add 100 div def
  196. /fillsat 100 rand 90 mod sub 100 div def
  197. /fillbright 100 rand 45 mod sub 20 add 100 div def
  198. /strokebright 100 rand 55 mod sub 100 div def
  199. /strokesat 100 rand 85 mod sub 100 div def
  200. } def
  201. /medjewel {
  202. /alt rand 2 mod def
  203. /backsat alt 0 eq {high} { med} ifelse def
  204. /fillsat alt 0 eq {med} {high} ifelse def
  205. /eosat alt 0 eq {high} {med} ifelse def
  206. /backbright med def
  207. /fillbright med def
  208. /eobright med def
  209. constroke 0 eq {
  210. /strokebright medlow def
  211. /strokesat high def
  212. }
  213. {
  214. /strokebright high def
  215. /strokesat medlow def
  216. } ifelse
  217. } def
  218. /medvivid {
  219. /alt rand 2 mod def
  220. /backsat alt 0 eq {1} { med} ifelse def
  221. /fillsat alt 0 eq {med} {1} ifelse def
  222. /eosat alt 0 eq {1} {med} ifelse def
  223. /backbright alt 0 eq {high} {med} ifelse def
  224. /eobright alt 0 eq {high} {med} ifelse def
  225. /fillbright alt 0 eq {med} {high} ifelse def
  226. constroke 0 eq {
  227. /strokesat 1 def
  228. /strokebright high def
  229. }
  230. {
  231. /strokesat high def
  232. /strokebright medlow def
  233. } ifelse
  234. } def
  235. /vivpastel {
  236. /backlight rand 2 mod def
  237. /backsat backlight 0 eq {medlow} {1} ifelse def
  238. /eosat backlight 0 eq {medlow} {1} ifelse def
  239. /fillsat backlight 0 eq {1} {medlow} ifelse def
  240. /fillbright high def
  241. /backbright high def
  242. /eobright high def
  243. constroke 0 eq {
  244. /strokesat 1 def
  245. /strokebright high def
  246. }
  247. {
  248. /strokesat high def
  249. /strokebright medlow def
  250. } ifelse
  251. } def
  252. /medpastel {
  253. /alt rand 2 mod def
  254. /backsat alt 0 eq {medlow} {med} ifelse def
  255. /eosat alt 0 eq {medlow} {med} ifelse def
  256. /fillsat alt 0 eq {med} {medlow} ifelse def
  257. /fillbright alt 0 eq { high } {med} ifelse def
  258. /backbright alt 0 eq {med} { high } ifelse def
  259. /eobright alt 0 eq {med} { high } ifelse def
  260. constroke 0 eq {
  261. /strokebright high def
  262. /strokesat medlow def
  263. }
  264. {
  265. /strokebright low def
  266. /strokesat high def
  267. } ifelse
  268. } def
  269. /maxcon {
  270. rand 2 mod 1 eq {
  271. /backsat 0 def
  272. /backbright 0 def
  273. /eosat 0 def
  274. /eobright 0 def
  275. /fillsat 0 def
  276. /fillbright 1 def
  277. /strokebright 1 def
  278. /strokesat 0 def
  279. }
  280. {
  281. /backsat 0 def
  282. /backbright 1 def
  283. /eosat 0 def
  284. /eobright 1 def
  285. /fillsat 0 def
  286. /fillbright 0 def
  287. /strokebright 0 def
  288. /strokesat 0 def
  289. }
  290. ifelse
  291. } def
  292. /monochrome {
  293. /fillhue hue closevary def
  294. /strokehue hue closevary def
  295. /eohue hue closevary def
  296. /backhue hue def
  297. } def
  298. /blackandwhite {
  299. /fillhue 1 def
  300. /eohue 0 def
  301. /backhue 0 def
  302. /strokehue 1 def
  303. } def
  304. /freecolor {
  305. /fillhue anyrand def
  306. /strokehue anyrand def
  307. /eohue anyrand def
  308. /backhue anyrand def
  309. } def
  310. /purple {
  311. /fillhue rand 15 mod 80 add 100 div def
  312. /backhue rand 15 mod 80 add 100 div def
  313. /strokehue rand 15 mod 80 add 100 div def
  314. /eohue rand 15 mod 80 add 100 div def
  315. /backhue rand 15 mod 80 add 100 div def
  316. } def
  317. /comptwo {
  318. /fillhue hue closevary def
  319. /strokehue hue .5 add dup 1 gt {1 sub} if def
  320. /backhue strokehue def
  321. /eohue strokehue closevary def
  322. } def
  323. /compthree {
  324. /backhue hue def
  325. /strokehue hue 1 3 div add dup 1 gt {1 sub} if closevary def
  326. /fillhue strokehue closevary def
  327. /eohue hue 1 3 div sub dup 1 lt { 1 add} if closevary def
  328. } def
  329. /origcolor {
  330. /backhue hue def
  331. /strokehue
  332. hue 1000 mul cvi 3 mod dup 1 eq
  333. {hue closevary}
  334. {2 eq
  335. {rand 999 mod 1000 div}
  336. {hue .5 add dup 1 gt {1 sub} if }
  337. ifelse
  338. }
  339. ifelse def
  340. /fillhue hue 1000 mul cvi 3 mod dup 1 eq
  341. {hue closevary}
  342. {2 eq
  343. {rand 999 mod 1000 div}
  344. {hue .5 add dup 1 gt {1 sub} if }
  345. ifelse
  346. }
  347. ifelse
  348. def
  349. /eohue hue 1000 mul cvi 2 mod 1 eq
  350. {hue closevary}
  351. {rand 999 mod 1000 div}
  352. ifelse def
  353. } def
  354. /harmtwo {
  355. /fillhue hue closevary def
  356. /backhue hue def
  357. /strokehue hue .2 add dup 1 gt {1 sub} if closevary def
  358. /eohue strokehue closevary def
  359. } def
  360. /harmfour {
  361. /fillhue hue closevary def
  362. /backhue hue .1 add dup 1 gt {1 sub} if def
  363. /strokehue hue .2 add dup 1 gt {1 sub} if closevary def
  364. /eohue hue .1 sub dup 1 lt {1 add} if closevary def
  365. } def
  366. /closeharm {
  367. /fillhue hue def
  368. /backhue hue .05 add dup 1 gt {1 sub} if closevary def
  369. /strokehue hue .1 add dup 1 gt {1 sub} if closevary def
  370. /eohue hue .05 sub dup 0 lt {1 add} if closevary def
  371. } def
  372. /high {100 rand 25 mod sub 100 div } def
  373. /med { rand 33 mod 33 add 100 div } def
  374. /medhigh {100 rand 50 mod sub 100 div } def
  375. /medlow {rand 50 mod 100 div } def
  376. /low { rand 25 mod 100 div} def
  377. /anyrand { rand 100 mod 100 div } def
  378. /closevary {rand 70 mod rand 100 mod sub 1000 div add} def
  379. %rainbow
  380. % {/colorfill {fillhue 1 1 sethsbcolor fill} def}
  381. /colorfill {fillhue fillsat fillbright sethsbcolor fill } def
  382. %ifelse
  383. /colorstroke {strokehue strokesat strokebright sethsbcolor stroke } def
  384. /eocolorfill {eohue eosat eobright sethsbcolor eofill } def
  385. /backfill{ backhue backsat backbright sethsbcolor fill } def
  386. /xstep { xrange xtimes 1 sub div x 1 sub mul } def
  387. /ystep { yrange ytimes 1 sub div y 1 sub mul} def
  388. /functionarray [
  389. {sin abs}
  390. {sin }
  391. {cos }
  392. {cos abs}
  393. {sin dup mul }
  394. {cos dup mul }
  395. {sin abs sqrt }
  396. {cos abs sqrt }
  397. ] def
  398. /range { /top exch def /bottom exch def /number exch def
  399. % number is between -1 and 1
  400. /rangesize top bottom sub def
  401. number 1 add 2 div
  402. % number is now between 0 and 1
  403. rangesize mul
  404. bottom add
  405. } def
  406. /drawone {
  407. /radius
  408. width height lt {width 3 div} {height 3 div} ifelse
  409. def
  410. seed srand
  411. 0 0 moveto
  412. /origmatrix [ 0 0 0 0 0 0 ] currentmatrix def
  413. [ % xstep function ystep function2 add .4 1.3 range
  414. 1
  415. ystep function xstep function add -.25 .25 range
  416. ystep function3 xstep function2 add -.5 .5 range
  417. % xstep function4 ystep function mul .4 1.3 range
  418. 1
  419. 0
  420. 0
  421. ]
  422. concat
  423. twist {twistdeg rotate} if
  424. part colorfill
  425. origmatrix setmatrix
  426. rainbow
  427. {/fillhue fillhue rainrange xtimes ytimes mul div add dup 1 gt {1 sub} if def}
  428. if
  429. } def
  430. /notdrawone {
  431. seed srand
  432. twist {/twistdeg rand 360 mod def} if
  433. nnrand {/nn rand 6 mod 3 add def} if
  434. /x1 rand width 3 div cvi mod width 8 div add def
  435. /y1 rand height 3 div cvi mod height 8 div add def
  436. rand 3 mod dup 1 eq
  437. {pop /x2 rand width 2 div cvi mod def
  438. /y2 rand height 2 div cvi mod def}
  439. { 2 eq
  440. {/x2 y1 def /y2 x1 def}
  441. {/x2 y1 width mul height div def /y2 x1 height mul width div def}
  442. ifelse
  443. }
  444. ifelse
  445. /radius width height gt {width} {height} ifelse 2.5 div def
  446. /stripe rand width 10 div cvi mod 2 add def
  447. starcompensate { /stripe stripe 2 mul def /radius radius 10 nn div mul def } if
  448. /i 1 def
  449. /repeats radius stripe div cvi 1 add def
  450. /nnincr 1 def
  451. repeats {
  452. colorvary {colorfam colorway} if
  453. /i i 1 add def
  454. /radius radius stripe sub def
  455. } repeat
  456. } def
  457. /page {
  458. clippath pathbbox /ury exch def /urx exch def /lly exch def /llx exch
  459. def
  460. /pagewidth urx llx sub def
  461. /pageheight ury lly sub def
  462. 0 0 moveto
  463. llx lly translate
  464. /outerwidth
  465. pagewidth inwidth div
  466. def
  467. /outerheight
  468. pageheight inheight div
  469. def
  470. /width
  471. outerwidth xtimes div
  472. def
  473. /height
  474. outerheight ytimes div
  475. def
  476. /size
  477. width height gt {width} {height} ifelse
  478. def
  479. inwidth {
  480. inheight {
  481. /seed rand def
  482. /hue rand 999 mod 1000 div def
  483. colorway colorfam
  484. /x 1 def /y 1 def
  485. nnrand {/nn rand 6 mod 3 add def} if
  486. /twistdeg rand 360 mod def
  487. /function functionarray rand functionarray length mod get def
  488. /function2 functionarray rand functionarray length mod get def
  489. /function3 functionarray rand functionarray length mod get def
  490. /function4 functionarray rand functionarray length mod get def
  491. /xrange [ 90 180 270 360 180 360 ] rand 6 mod get def
  492. /yrange [ 90 180 270 360 180 360 ] rand 6 mod get def
  493. initclip
  494. newpath
  495. 0 0 moveto
  496. outerwidth 0 rlineto
  497. 0 outerheight rlineto
  498. outerwidth neg 0 rlineto
  499. backfill
  500. xtimes {
  501. ytimes{
  502. /y y 1 add def
  503. width 2 div height 2 div translate
  504. drawone
  505. width 2 div neg height 2 div neg translate
  506. 0 height translate
  507. } repeat
  508. /y 1 def
  509. /x x 1 add def
  510. width height ytimes mul neg translate
  511. } repeat
  512. width xtimes mul neg outerheight translate
  513. } repeat
  514. outerwidth outerheight inheight mul neg translate
  515. } repeat
  516. } def
  517. page showpage
  518. clear cleardictstack
  519. vasarelysave restore