simple graphics example wanted

Ron Wichers Schreur ronny@cs.kun.nl
Thu, 27 Nov 1997 21:19:17 +0100


Tuomas asks (to the Clean discussion list):

> Could someone give a very short example how to draw a line on
> screen with ObjectIO? ( Plain line or point, no menus or 
> anything else. ) The included graphical examples work nicely,
> but I can't see where the actual drawing is done :-).

    module Line
    import StdEnv, StdIO
    :: NoState = NoState // this program doesn't use any state

    Start :: *World -> *World
    Start world
        // start the interaction
        =   startIO NoState NoState [initialise] [] world
	where
            // create a window to draw in
      	    initialise state
                =   snd (openWindow NoState window state)
            window
                =   Window "Line" NilLS [WindowLook look]
            // the update function: draw a line
            look selectState updateState
                =   [drawAt {x = 0, y = 0} {vx = 100, vy = 100}]

Because there are no menus or controls, there's no way to quit
this program (use Force Quit on the Macintosh). The drawing is done
through the window's update function. This function returns a list
of drawing fuctions that are applied to the window when an update
is necessary.


Cheers,

Ronny Wichers Schreur