home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 November / PCO_1198.ISO / filesbbs / os2 / tspg202s.arj / TSPG202S.ZIP / Scripts / STARFIEL.CWX < prev   
Encoding:
Text File  |  1997-05-04  |  1.8 KB  |  75 lines

  1. /*
  2.  
  3.   starfld.cwx
  4.  
  5.   This script draws a starfield on a black background the size of the output area.
  6.   If the background is already there, it just draws the stars.
  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.  
  17.  
  18. /* Get the current output rectangle. */
  19. output_settings = CwGetAppHandle('output settings')
  20. field.w = CwGetProperty(output_settings, "output size:width")
  21. field.h = CwGetProperty(output_settings, "output size:height")
  22. dim = .1
  23.  
  24.  
  25. /* See if there's a big back background.  If not, create it.*/
  26. bbb = CwGetHandleFromObjectName(CwGetCurrentView(), 'black background')
  27. if \CwIsHandleValid(bbb) then do
  28.     f = CwCreateEffect( 'Rectangle', 'Solid Color' )
  29.     s = CwGetTool(f);
  30.     call CwSetProperty s, 'Color', 'black'
  31.     call CwSetProperty f, 'Name', 'black background'
  32.     call CwSetPosition f, field.w/2, field.h/2, field.w, field.h, 0, 0
  33.     end
  34.  
  35.  
  36. /* Draw 50 stars. */
  37. do i = 1 to 50
  38.     dim = rand(.05, .2)
  39.     x = rand(dim/2, field.w - dim/2)
  40.     y = rand(dim/2, field.h - dim/2)
  41.     call star x, y, dim
  42.     end
  43.  
  44. exit
  45.  
  46.  
  47.  
  48.  
  49. /* Return an random number between FROM and TO.  (REXX's random function is gross.) */
  50. rand:procedure        
  51. arg from, to;
  52.  
  53. r = random(0, 999) / 1000
  54. return (to - from) * r + from
  55.  
  56.  
  57.  
  58.  
  59. /* A Star is Born. */
  60. star:procedure
  61. parse arg x, y, dim
  62.  
  63. star = CwCreateEffect( 'Ellipse Fade', 'Solid Color' )
  64.  
  65. solid = CwGetTool(star)
  66. call CwSetProperty solid, 'Color', 'white'
  67.  
  68. ell = CwGetRegion(star)
  69. call CwSetProperty ell, 'Density', 35
  70.  
  71. call CwSetPosition star, x, y, dim, dim, 0, 0
  72. return;
  73.  
  74.  
  75.