home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / euphor10.zip / SB.EX < prev    next >
Text File  |  1993-06-18  |  2KB  |  86 lines

  1.         ------------------------------------------
  2.         -- Make Your Own "Screen Blank" Program --
  3.         ------------------------------------------
  4.  
  5. -- change some of these parameters to get weird effects:
  6. -- (on SVGA this looks pretty good: MODE=261, NLINES=70, NPOINTS=6, 
  7. --  SPACING=12, WIDTH=1, SOLID=0, DELAY=80000 (486-50))
  8. constant MODE = 261,    -- graphics mode -- see euphoria\include\graphics.e
  9.      NLINES = 70,   -- number of lines on screen at one time
  10.      NPOINTS = 6,   -- number of points in polygons
  11.      SPACING = 12,  -- spacing between lines
  12.      WIDTH = 1,     -- line width
  13.      SOLID = 0,     -- solid polygons? 1 or 0
  14.      DELAY = 0      -- slow it down
  15. -----------------------------------------------------------------------------
  16. without type_check
  17.  
  18. include graphics.e
  19. include select.e
  20.  
  21. constant X = 1,
  22.      Y = 2
  23.  
  24. sequence config
  25.  
  26. procedure screen_blank()
  27.     integer color, color_step, ncolors
  28.     sequence points, deltas, history
  29.  
  30.     if not select_mode(MODE) then
  31.     puts(1, "couldn't find a good graphics mode\n")
  32.     return
  33.     end if
  34.     config = video_config()
  35.     ncolors = config[VC_NCOLORS]
  36.     color = 1
  37.     color_step = 1
  38.     points = rand(repeat(config[VC_XPIXELS..VC_YPIXELS], NPOINTS)) - 1
  39.     deltas = rand(repeat({2*SPACING-1, 2*SPACING-1}, NPOINTS)) - SPACING
  40.     history = {}
  41.     while 1 do
  42.     if length(history) >= NLINES then
  43.         -- blank out oldest line
  44.         polygon(0, WIDTH, SOLID, history[1])
  45.         history = history[2..NLINES]
  46.     end if
  47.     polygon(color, WIDTH, SOLID, points)
  48.     history = append(history, points)
  49.        points = points + deltas
  50.     -- make vertices change direction at edge of screen
  51.     for j = 1 to NPOINTS do
  52.         if points[j][X] <= 0 or points[j][X] >= config[VC_XPIXELS] then
  53.         deltas[j][X] = -deltas[j][X]
  54.         end if
  55.         if points[j][Y] <= 0 or points[j][Y] >= config[VC_YPIXELS] then
  56.         deltas[j][Y] = -deltas[j][Y]
  57.         end if
  58.     end for
  59.     -- step through the colors
  60.     color = color + color_step
  61.     if color >= ncolors then
  62.         color_step = rand(ncolors)
  63.         color = color_step
  64.     end if
  65.     -- change background color once in a while
  66.     if rand(80) = 1 then
  67.         bk_color(rand(ncolors)-1)
  68.     end if
  69.     -- see if user wants to quit
  70.     if get_key() != -1 then
  71.         return
  72.     end if
  73.     -- slow it down a bit
  74.     for j = 1 to DELAY do
  75.     end for
  76.     end while
  77. end procedure
  78.  
  79. screen_blank()
  80.  
  81. if config[VC_COLOR] then
  82.     graphics_mode(3)
  83. else
  84.     graphics_mode(7)
  85. end if
  86.