On this page:
init-world
set-on-tick-event
stop-tick
set-on-key-event

5 World Operations

Every canvas comes with an associated world. A client program can set the world, start the world’s clock, stop the world’s clock, and deal with tick events (the clock ticks) and keyboard inputs (keyevents).

procedure

((init-world viewport) v)  void?

  viewport : viewport?
  v : any/c
Sets the initial value of viewport’s world to v.

procedure

((set-on-tick-event viewport)    
  secs    
  update-callback)  void?
  viewport : viewport?
  secs : real?
  update-callback : (any/c . -> . any/c)
For viewport, sets update-callback to be invoked to transform the world value every secs seconds. Only one callback is installed at a time.

procedure

((stop-tick viewport))  void?

  viewport : viewport?
Stops updating viewport’s world via a callback installed with set-on-tick-event.

procedure

((set-on-key-event viewport) key-callback)  void?

  viewport : viewport?
  key-callback : (any/c any/c . -> . any/c)
Sets key-callback as the function to call whenever a key event is received for viewport. The key-callback is given a key event and the current world, and it produces an updated world.