( "world" :dir :teachpacks)
This teachpack provides a datatype for images and a framework for interactive animations. It is partially reflected in the ACL2 logic, but some of the primitives cannot be fully reasoned about or executed due by ACL2 to their imperative and platform-specific nature.
These forms produce an interactive animation that reacts to events. The user must define a World datatype, representing the state of an animation, and functions to update the World in response to events such as keystrokes or mouse buttons. From this, the teachpack can generate an interactive animation.
Events are based on two extra datatypes. A KeyEvent represents a keystroke, and may be either a character or a symbol such as 'left, 'right, 'up, or 'down. A MouseEvent represents an action of the mouse cursor, and may be 'button-down, 'button-up, 'drag, 'move, 'enter, or 'leave.
Starts an animation, given a width and height for each frame, the time in seconds between clock ticks, and the initial World value.
draw : World -> image?
Registers a function to draw each frame of an animation.
game-over : World -> boolean?
Registers a function to report when the animation has ended.
tick : World -> World
Registers a function to update the world each time the clock ticks.
press : World KeyEvent -> World
Registers a function to update the world each time the user presses or releases a key.
Registers a function to update the world each time the user moves or clicks the mouse.
These primitives operate on images intended as complete animation frames.
Produces a blank scene of the given dimensions from which to construct an animation frame.
img : image?
scn : image?
Adds img to scn at the given coordinates.
These primitives construct images as first-class values.
These functions construct images of various geometric shapes.
color : image-color?
Constructs an image of text.
i : image?
c : image-color?
Adds a line from (x1,y1) to (x2,y2) of color c to i.
These functions place one image over another. The first overlays a number of images as they are; the second overlays one image at an offset on another.
These functions compute the dimensions of an image.
These functions deal with an image’s pinhole, the point on which overlay places other images and from which place-image calculates offsets.
Recognizes image drawing modes: 'solid or 'outline.
Recognizes colors constructed with make-color, or color names as strings or symbols. Color names include:
DarkRed, Red, LightPink, Pink, Brown, DarkOrange, Orange, Yellow, LightYellow, Green, DarkGreen, LightGreen, Cyan, LightBlue, LightCyan, DarkBlue, Blue, Purple, Magenta, DarkMagenta, Violet, White, LightGray, Gray, DarkGray, and Black.
These functions (constructor, selectors, and predicate) define a datatype of colors based on red, green, and blue values between 0 and 255.
Recognizes integers between 0 and 255, inclusive.
Posns are structures representing positions in two-dimensional space. These procedures correspond to the constructor, selectors, predicate, and weak predicate for Posns.