Difference between revisions of "SolidColorDisplay"
(added an example) |
(Added fade out/in example) |
||
Line 14: | Line 14: | ||
|} | |} | ||
− | == | + | == Examples == |
The following example sets the background (display 7) to blue, and also clears the pixel display (layer 5) to clear so that the background can be seen. | The following example sets the background (display 7) to blue, and also clears the pixel display (layer 5) to clear so that the background can be seen. | ||
Line 21: | Line 21: | ||
display(7).color = color.blue | display(7).color = color.blue | ||
display(5).clear color.clear</ms> | display(5).clear color.clear</ms> | ||
+ | |||
+ | The next example does a "fade to black" by setting display 0 (the topmost layer) to solid color, and gradually changing it from completely transparent to solid black. Then, after waiting for the user to press a key, it fades back to transparent, making everything behind it appear to "fade in." | ||
+ | |||
+ | <ms>display(0).mode = displayMode.solidColor | ||
+ | fader = display(0) | ||
+ | for alpha in range(0, 255, 3) | ||
+ | fader.color = color.rgba(0,0,0, alpha) | ||
+ | yield | ||
+ | end for | ||
+ | |||
+ | key.get // wait for a keypress | ||
+ | |||
+ | for alpha in range(255, 0, -3) | ||
+ | fader.color = color.rgba(0,0,0, alpha) | ||
+ | yield | ||
+ | end for | ||
+ | display(0).mode = displayMode.off</ms> | ||
[[Category:Mini Micro]] | [[Category:Mini Micro]] |
Latest revision as of 17:15, 10 February 2025
The SolidColorDisplay
class in Mini Micro is a display type that represents a single color over the entire screen. It is often used to control overall background color of the screen, or as an overlay to fade the rest of the displays in or out.
Note that "solid" here refers to the entire display layer being one color. It does not imply that this color must be opaque; translucent colors work perfectly well.
By default, display 7 is configured as a solid black display (by the clear command).
Methods and Properties
Method or Property | Purpose |
---|---|
SolidColorDisplay.color | get or set the color of the display layer |
Examples
The following example sets the background (display 7) to blue, and also clears the pixel display (layer 5) to clear so that the background can be seen.
clear
display(7).color = color.blue
display(5).clear color.clear
The next example does a "fade to black" by setting display 0 (the topmost layer) to solid color, and gradually changing it from completely transparent to solid black. Then, after waiting for the user to press a key, it fades back to transparent, making everything behind it appear to "fade in."
display(0).mode = displayMode.solidColor
fader = display(0)
for alpha in range(0, 255, 3)
fader.color = color.rgba(0,0,0, alpha)
yield
end for
key.get // wait for a keypress
for alpha in range(255, 0, -3)
fader.color = color.rgba(0,0,0, alpha)
yield
end for
display(0).mode = displayMode.off