Difference between revisions of "Display.install"
Line 17: | Line 17: | ||
=== Known Issues === | === Known Issues === | ||
Installing a [[PixelDisplay]] resets its [[PixelDisplay.color|color]] to white. (Do not depend on this behavior; it may change in a future release.) | Installing a [[PixelDisplay]] resets its [[PixelDisplay.color|color]] to white. (Do not depend on this behavior; it may change in a future release.) | ||
− | |||
− | |||
=== Example === | === Example === |
Revision as of 01:07, 7 February 2023
Display.install
installs a Display into one of the eight display layers in the Mini Micro virtual machine, replacing (and detaching) the previous display in that layer.
Contents
Arguments
Parameter Name | Type | Default Value | Meaning |
---|---|---|---|
index | number | 0 | display layer to install into, from 0 (frontmost) to 7 (back) |
Usage Notes
Any Display object is either installed in one of the 8 display layers, or it is detached (off-screen). A display created with new
is initially detached. It may be configured, drawn into, and otherwise used, but will be completely invisible to the user until it is installed by calling this method.
This may be used for page flipping: preparing a number of uninstalled (off-screen) displays ahead of time, and then installing them on the screen one at a time to produce animation. Installation of a display is very fast, so even if the preparation (drawing) takes a while, you can produce very smooth, flicker-free animation this way. (See example below.)
Known Issues
Installing a PixelDisplay resets its color to white. (Do not depend on this behavior; it may change in a future release.)
Example
This example demonstrates the page flipping technique by preparing 20 off-screen PixelDisplays, each with a different drawing of a clock hand. The displays are then installed successively into layer 5, creating an animated clock. (Note that for such simple drawing, page flipping is not necessary; but it makes a good example.)
clear
pages = []
for i in range(0,19)
p = new PixelDisplay // create a detached PixelDisplay
p.clear color.black
ang = 2*pi/20 * i
p.line 480,320, 480+300*cos(ang), 320+300*sin(ang), color.yellow, 20
pages.push p
end for
curPage = 0
while true
pages[curPage].install 5 // install next PixelDisplay in layer 5
wait 1
curPage = (curPage+1) % 20
end while