home *** CD-ROM | disk | FTP | other *** search
- /* A sample graphics stand-alone application */
- /* This draws a spectrum in a frame window on the screen, using
- and off-screen image to hold the current picture */
-
- options binary -- optional, for speed
-
- class Spectrum extends Frame -- a window object
-
- shadow=Image -- where we'll build the image
-
- /* The 'main' method is called when this class is started as an application */
- method main(s=String[]) static
- frame=Spectrum("My Spectrum" Rexx(s)) -- make a titled frame
- frame.resize(200,200) -- size it
- frame.show -- and make it visible
-
- /* The constructor for Spectrum just passes the title to superclass */
- method Spectrum(s=String)
- super(s)
-
- /* Update is called when the display content needs updating */
- method update(g=Graphics)
- shadow=createImage(size.width, size.height) -- make new image
- d=shadow.getGraphics -- context for graphics
- maxx=size.width-1
- maxy=size.height-1
- loop y=0 to maxy
- col=Color.getHSBColor(y/maxy, 1, 1) -- select a colour
- d.setColor(col) -- set it
- d.drawRect(0, y, maxx, y) -- and fill a slice
- end y
- paint(g) -- paint to screen
-
- /* Paint is called when the window needs to be redrawn, either by
- update or when a window is uncovered */
- method paint(g=Graphics)
- if shadow=null then update(g) -- (no image yet)
- g.drawImage(shadow, 0, 0, this) -- copy to screen
-
- /* We need a handleEvent method to ensure Close works properly */
- method handleEvent(e=Event) returns boolean
- if e.id=Event.WINDOW_DESTROY then exit -- exit on close
- return super.handleEvent(e) -- otherwise take default action
-
-