home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / netrexx.zip / NetRexx / ArchText.nrx < prev    next >
Text File  |  1997-06-30  |  2KB  |  50 lines

  1. /* ArchText applet: multi-coloured text on a white background */
  2. /* Mike Cowlishaw  April 1996,  December 1996                 */
  3. options binary
  4.  
  5. class ArchText extends Applet implements Runnable
  6.  
  7.  text  ="NetRexx"                             /* default text */
  8.  tick  =0                                  /* display counter */
  9.  timer =Thread null                           /* timer thread */
  10.  shadow=Image                                 /* shadow image */
  11.  draw  =Graphics                         /* where we can draw */
  12.  
  13.  method init
  14.   s=getParameter("text")             /* get any provided text */
  15.   if s\=null then text=s
  16.   shadow=createImage(getSize.width, getSize.height)  /* image */
  17.   draw=shadow.getGraphics
  18.   draw.setColor(Color.white)                    /* background */
  19.   draw.fillRect(0, 0, getSize.width, getSize.height)    /* .. */
  20.   draw.setFont(Font("TimesRoman", Font.BOLD, 30))     /* font */
  21.  
  22.  method start
  23.   if timer=null then timer=Thread(this)         /* new thread */
  24.   timer.setPriority(Thread.MAX_PRIORITY)      /* time matters */
  25.   timer.start                             /* start the thread */
  26.  
  27.  method stop
  28.   if timer=null then return                 /* have no thread */
  29.   timer.stop                                  /* else stop it */
  30.   timer=null                                /* .. and discard */
  31.  
  32.  method run                            /* this runs as thread */
  33.   loop while timer\=null
  34.     tick=tick+1                                /* next update */
  35.     hue=((tick+133)//191)/191
  36.     draw.setColor(Color.getHSBColor(hue, 1, 0.7))
  37.     draw.drawString(text, 0, 30)
  38.     this.repaint                             /* .. and redraw */
  39.     Thread.sleep(119)                          /* wait awhile */
  40.   catch InterruptedException
  41.   end
  42.   timer=null                                       /* discard */
  43.  
  44.  method update(g=Graphics)        /* override Applet's update */
  45.   paint(g)                         /* method to avoid flicker */
  46.  
  47.  method paint(g=Graphics)
  48.   g.drawImage(shadow, 0, 0, null)
  49.  
  50.