|(require lux)||package: lux|
The lux module provides an efficient way to build interactive programs that consist of plain mathematical functions. It is comparable to 2htdp/universe, although designed to allow more parameterization of how the program interacts.
Check out some examples in the examples directory in the source.
1 Structure of a lux Program
A lux program chooses how it will interact be selecting a chaos and calling call-with-chaos with that chaos and a thunk that calls fiat-lux with a word. fiat-lux may be called any number of nested times within a call to call-with-chaos. Each subsequent fiat-lux takes over the chaos until the word completes. It is not typically possible to use words with arbitrary chaoses, as the chaos specifies how the word interacts through events and output values.
A word is a generic interface the encapsulates the interactive behavior of a lux program.
The word methods are as follows:
|(require lux/chaos/gui)||package: lux|
(or/c (one-of/c 'draw 'gl-compat 'gl-core) (is-a?/c gl-config%)) = 'draw opengl-hires? : boolean? = #f start-fullscreen? : boolean? = #f frame-style : (listof symbol?) = '() icon : (or/c #f path-string? (is-a?/c bitmap%)) = #f
x : (or/c exact-nonnegative-integer? (one-of/c 'left 'center 'right)) = 'center
y : (or/c exact-nonnegative-integer? (one-of/c 'top 'center 'bottom)) = 'center width : exact-nonnegative-integer? = 800 height : exact-nonnegative-integer? = 600 monitor : (or/c false/c exact-nonnegative-integer?) = #f
The canvas is set up for drawing based on mode. If mode is 'draw, then the canvas assumes that racket/draw is used. If other values are used, then the canvas is drawn with OpenGL. If mode is 'gl-compat, then a compatibility OpenGL profile is used. If mode is 'gl-core, then a core OpenGL profile is used. If mode is a gl-config% object, then it is used to initialize the canvas. If opengl-hires? is #t, then the resulting gl-config% object will have high resolution mode set.
The values that word-event is called with are either 'close (for when the window’s close button is pressed), a key-event% object for when keys are pressed, or a mouse-event% object for when the mouse is used.
The values that word-output should return are functions that satisfy the contract (-> real? real? (is-a?/c dc<%>) any) where the first argument is the width of the canvas, the second is the height, and the third is the canvas’s drawing context.
|(require lux/chaos/gui/val)||package: lux|
This module provides a helpful function for drawing functional images with lux/chaos/gui.
(make-gui/val [#:scale? scale?])
(-> pict-convertible? (-> real? real? (is-a?/c dc<%>) any)) scale? : boolean? = #t
|(require lux/chaos/gui/key)||package: lux|
This module provides a set of functions for tracking keyboard state for use inside of word-tick, rather than updating word state with each event as in word-event. Such as system may be appropriate for interactive programs where input is only has an impact at a consistent tick rate.
→ (or/c (cons/c 'release (or/c char? key-code-symbol?)) (or/c char? key-code-symbol?)) ke : key-event?
|(require lux/chaos/gui/mouse)||package: lux|
This module provides a set of functions for tracking mouse state for use inside of word-tick, rather than updating word state with each event as in word-event. Such as system may be appropriate for interactive programs where input is only has an impact at a consistent tick rate.
|(require lux/chaos/pair)||package: lux|
|(require lux/chaos)||package: lux|
The chaos methods are as follows: