FileStream fileIn: 'loadscript.st'. Object subclass: Demo [ | context | context [ ^context ] winningDirectAccess [ | color result | Display critical: [ color := Display mapRed: 100 green: 200 blue: 255. result := Display fillRect: (10@10 extent: 100@100) color: color]. Display flip. ] winningCairo [ context := CairoContext onSurface: (CairoSdlSurface onSdlForm: Display). Display critical: [ context setSourceRed: 1.0 green: 1.0 blue: 1.0; setLineWidth: 20.0; newPath; moveTo: 0 @ 0; lineTo: 100 @ 100; stroke]. Display flip. ] run [ SdlEventSource instance handler: self. self winningDirectAccess. self winningCairo. Processor activeProcess terminateOnQuit. self blitStuff. ] randomColorComponent [ ^ ((Random between: 0 and: 255) / 255) asFloat ] blitStuff [ | maxw maxh x y w h startTime count | startTime := Time millisecondClock. count := 0. maxw := Display extent x. maxh := Display extent y. [ x := Random between: 0 and: maxw. y := Random between: 0 and: maxh. w := Random between: 0 and: maxw - x. h := Random between: 0 and: maxh - y. Display critical: [ context setSourceRed: self randomColorComponent green: self randomColorComponent blue: self randomColorComponent; newPath; rectangle: (x@y extent: w@h); fill]. count := count + 1. (count \\ 100) = 0 ifTrue: [ Display flip. Transcript << count << ' frames, ' << (count / ((Time millisecondClock - startTime) / 1000.0)) << ' fps'; nl. Processor yield]. ] repeat. ] handleMouseMotion: which state: state x: x y: y xRel: xRel yRel: yRel [] handleMouseButton: which button: button state: state x: x y: y [] handleFocusLoss [] handleFocusGain [] handleWMQuitRequest [ Transcript << 'handleWMQuitRequest'; nl. (ObjectMemory snapshot: 'demo.im') ifFalse: [ "false -> not resuming" Transcript << 'about to quit after snapshot'; nl. ObjectMemory quit]. ] ]. Eval [ | s | s := Semaphore new. [ [ Demo new run. ] ensure: [ s signal ] ] fork. s wait. ]