home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 November / PCO_1198.ISO / filesbbs / os2 / tspg202s.arj / TSPG202S.ZIP / Scripts / ABSTRACT.CWX next >
Encoding:
Text File  |  1997-05-04  |  7.6 KB  |  295 lines

  1. /*
  2.  
  3.   abstract.cwx
  4.  
  5.   This is the paint-and-dynamite abstract art script.  It creates a
  6.   random number of objects in the current view.
  7.  
  8.   Copyright 1997 by TrueSpectra Inc.
  9.  
  10.   This code is provided purely for demonstration purposes and is not
  11.   supported or under warranty.  Feel free to modify and examine this
  12.   example script for your own purposes.
  13. */
  14.  
  15.  
  16. /* Load utility functions. */
  17. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  18. call SysLoadFuncs
  19.  
  20.  
  21.  
  22. /* A long string, fragments of which go into headline text objects.*/
  23. wurds = "On the road, ZIPPY is a pinhead without a purpose, but never" ,
  24. "Why do you say without a point?" ,
  25. "Yow!  We're going to a new disco!" ,
  26. "Is it because of your plans that you say we're going to a new disco?" ,
  27. "Yow!  Are you the self-frying president?" ,
  28. "Maybe your life have something to do with this." ,
  29. "SHHHH!!  I hear SIX TATTOOED TRUCK-DRIVERS tossing ENGINE BLOCKS" ,
  30. "into empty OIL DRUMS.." ,
  31. "What makes you believe into empty oil drums?" ,
  32. "I HAVE to buy a new ``DODGE MISER'' and two dozen JORDACHE" ,
  33. "JEANS because my viewscreen is ``USER-FRIENDLY''!!" ,
  34. "Is it because your viewscreen is user friendly'' that you came to me?" ,
  35. "I haven't been married in over six years, but we had sexual counseling" ,
  36. "every day from Oral Roberts!!" ,
  37. "Earlier you said your viewscreen is user friendly''?" ,
  38. "Spreading peanut butter reminds me of opera!!  I wonder why?" ,
  39. "Can you elaborate on that?" ,
  40. "Yow!  I threw up on my window!" ,
  41. "Is it because of the people you hang around with that you are going" ,
  42. "through all this?" ,
  43. "If Robert Di Niro assassinates Walter Slezak, will" ,
  44. "Jodie Foster marry Bonzo??" ,
  45. "Is it because of problems at school that you say jodie foster marry"
  46.  
  47. lwurds = 199
  48.  
  49.  
  50. /* Zippy the Pinhead quotes--these get put into block text objects.*/
  51.  
  52. line.1 = "My pants just went to high school in the Carlsbad Caverns!!!"
  53. line.2 = "I represent a sardine!!"
  54. line.3 = "Are you mentally here at Pizza Hut??"
  55. line.4 = "Civilization is fun!  Anyway, it keeps me busy!!"
  56. line.5 = "Now I'm concentrating on a specific tank battle toward" ,
  57.     "the end of World War II!"
  58. line.6 = "Edwin Meese made me wear CORDOVANS!!"
  59. line.7 = "I just forgot my whole philosophy of life!!!"
  60. line.8 = "I'm reporting for duty as a modern person.  I want to do the Latin Hustle now!"
  61. line.9 = "Are you mentally here at Pizza Hut??"
  62. line.10 = "But was he mature enough last night at the lesbian masquerade?"
  63. line.11 = "Everybody gets free BORSCHT!"
  64. line.12 = "Where's the Coke machine?  Tell me a joke!!"
  65. line.13 = "..  I wonder if I ought to tell them about my PREVIOUS LIFE" ,
  66.     "as a COMPLETE STRANGER?"
  67. line.14 = "A dwarf is passing out somewhere in Detroit!"
  68. line.15 = "I feel partially hydrogenated!"
  69. line.16 = "A shapely CATHOLIC SCHOOLGIRL is FIDGETING inside my costume.."
  70. line.17 = "Content:  80% POLYESTER, 20% DACRON..  The waitress's" ,
  71.     "UNIFORM sheds TARTAR SAUCE like an 8'' by 10'' GLOSSY.."
  72. line.18 = "Can you MAIL a BEAN CAKE?"
  73. line.19 = "It's the RINSE CYCLE!!  They've ALL IGNORED the RINSE CYCLE!!"
  74. line.20 = "As President I have to go vacuum my coin collection!"
  75. line.21 = "I'd like some JUNK FOOD...  and then I want to be ALONE --"
  76. line.22 = "I want to kill everyone here with a cute colorful Hydrogen Bomb!!"
  77. line.23 = "The FALAFEL SANDWICH lands on my HEAD and I become a VEGETARIAN..."
  78. line.24 = "Can I have an IMPULSE ITEM instead?"
  79. line.25 = "Do you think the ``Monkees'' should get gas on odd or even days?"
  80. line.26 = "I want you to MEMORIZE the collected poems of" ,
  81.     "EDNA ST VINCENT MILLAY.. BACKWARDS!!"
  82. nlines = 26
  83.  
  84.  
  85. /* Those bitmap formats I can be bothered with.*/
  86. bmext.1 = 'gif'
  87. bmext.2 = 'jpg'
  88. bmext.3 = 'tiff'
  89. bmext.4 = 'bmp'
  90. nbmext = 4
  91.  
  92.  
  93. nbitmaps = 0
  94.  
  95. ah = CwGetAppHandle('preferences')
  96. searchpath = CwGetProperty(ah, "Bitmap Path")
  97.  
  98. do while length(searchpath) > 0
  99.     n = pos(';', searchpath, 1)
  100.         if n = 0 then
  101.         n = length(searchpath)+1
  102.     path = substr(searchpath, 1, n-1)
  103.     searchpath = substr(searchpath, n+1)
  104.     do c = 1 to nbmext
  105.         call getfiles path, bmext.c
  106.         end
  107.     end
  108.  
  109.  
  110. /* Create the objects and exit.*/
  111. do random(1,100)
  112.     call randobj
  113.     end
  114. exit
  115.  
  116.  
  117.  
  118.  
  119. /* Get bitmap files. */
  120. getfiles:procedure expose bitmaps. nbitmaps
  121. parse arg path, ext
  122.  
  123. if substr(path, length(path)) \= "\" then
  124.     path = path || "\"
  125.  
  126. rc = SysFileTree(path||'*.'||ext, 'files', 'FSO')
  127.  
  128. if rc = 2 then do
  129.     say "REXX error."
  130.     exit
  131.     end
  132.  
  133. do i = 1 to files.0
  134.     nbitmaps = nbitmaps + 1
  135.     bitmaps.nbitmaps = files.i
  136.     end
  137. return
  138.  
  139.  
  140.  
  141. /* Create a random object. */
  142. randobj:procedure expose wurds lwurds line. nlines bitmaps. nbitmaps
  143.  
  144. ah=CwGetAppHandle('output settings')
  145. maxwidth=CwGetProperty(ah, 'output size:width')
  146. maxheight=CwGetProperty(ah, 'output size:height')
  147.  
  148. mw=maxwidth/2
  149. mh=maxheight/2
  150. mx = maxwidth
  151. my = maxheight
  152.  
  153. /* Need these to generate types. */
  154. region.1.name = "Custom Region";
  155. region.2.name = "User Draw";
  156. region.3.name = "Ramp";
  157. region.4.name = "Ellipse Fade";
  158. region.5.name = "Headline Text";
  159. region.6.name = "Block Text";
  160. region.7.name = "Rectangle";
  161. region.8.name = "Ellipse";
  162. region.9.name = "Shape";
  163. nregions = 9;
  164.  
  165. tool.1.name = "Custom Tool";
  166. tool.2.name = "Bitmap";
  167. tool.3.name = "Solid Color";
  168. tool.4.name = "Wave";
  169. tool.5.name = "Lens";
  170. tool.6.name = "Emboss";
  171. tool.7.name = "Contrast & Brightness";
  172. tool.8.name = "Greyscale";
  173. tool.9.name = "Color Fade";
  174. tool.10.name = "Button";
  175. tool.11.name = "Noise";
  176. tool.12.name = "Pixelate";
  177. tool.13.name = "Blur";
  178. tool.14.name = "Sharpen";
  179. ntools = 14;
  180.  
  181. /* Pick tools.  For the moment, don't get custom tools or regions. */
  182. t=random(2,ntools)
  183. r=random(3,nregions)
  184.  
  185. x = rand(0, mx)
  186. y = rand(0, my)
  187. w = rand(.01, mw)
  188. h = rand(.01, mh)
  189. rot = rand(0, 360)
  190. shear = rand(0, 80)
  191.  
  192. o = CwCreateEffect(region.r.name, tool.t.name)
  193. call CwSetPosition o, x, y, w, h, rot, shear
  194.  
  195. if r = 5 then
  196.     call word o
  197. else if r = 6 then
  198.     call sentence o
  199.  
  200. if t = 2 then
  201.     call bitmap o
  202.  
  203. call Colors o
  204.  
  205. return o
  206.  
  207.  
  208.  
  209.  
  210. /* My random number generator. */
  211.  
  212. rand:procedure        
  213. arg from, to;
  214.  
  215. r = random(0, 999) / 1000
  216. return (to - from) * r + from
  217.  
  218.  
  219.  
  220. /* Set the text of a block-text object. */
  221.  
  222. sentence:procedure expose line. nlines
  223. parse arg handle
  224.  
  225. n = random(1, 26)
  226. text = line.n
  227. call CwSetProperty CwGetRegion(handle), "Caption", text
  228. return
  229.  
  230.  
  231.  
  232.  
  233. /* Set the text of a headline-text object. */
  234.  
  235. word:procedure expose wurds lwurds
  236. parse arg handle
  237.  
  238. p = random(1,lwurds)
  239. n = random(1, 5)
  240. text = subword(wurds, p, n)
  241. call CwSetProperty CwGetRegion(handle), "Caption", text
  242. return
  243.  
  244.  
  245.  
  246.  
  247. /* Randomly set the Colors of the given parameter. */
  248.  
  249. Colors:procedure
  250. parse arg object
  251.  
  252. tool = CwGetTool(object)
  253.  
  254. /* See if it has Color. */
  255. if CwHasProperty(tool, "Color") then do
  256.     call CwSetProperty tool, "Color", randColor()
  257.     end
  258.  
  259. /* See if it's a Color-fade.*/
  260. else if CwHasProperty(tool, "Top-left:HSV Color") then do
  261.     call CwSetProperty tool, "Top-Left:HSV Color", randColor()
  262.     call CwSetProperty tool, "Top-Right:HSV Color", randColor()
  263.     call CwSetProperty tool, "Bottom-Left:HSV Color", randColor()
  264.     call CwSetProperty tool, "Bottom-Right:HSV Color", randColor()
  265.     end
  266. return
  267.  
  268.  
  269.  
  270. /* Return a random Color. */
  271.  
  272. randColor:procedure
  273.  
  274. r=random(1,255)
  275. g=random(1,255)
  276. b=random(1,255)
  277.  
  278. return "("||r||","||g||","||b||")"
  279.  
  280.  
  281.  
  282.  
  283. /* Randomly assign a bitmap value to the object. */
  284. bitmap:procedure expose bitmaps. nbitmaps
  285. parse arg object
  286.  
  287. if nbitmaps > 0 then do
  288.     tool = CwGetTool(object)
  289.     bm = random(1, nbitmaps)
  290.     bmn = bitmaps.bm
  291.     
  292.     call CwSetProperty tool, 'Image', bmn
  293.     end
  294. return
  295.