color
Color constants and conversions, on every target, Flash Apps included.
Calls with constant arguments are worked out at compile time, so they add no conversion code to your program:
from ti84 import color, graphics
TEAL = color.from_rgb(0, 128, 128)
graphics.fill_rect(0, 0, 50, 50, TEAL)
Classic colors
The classic screen has no color, so values are 0 for white and 1 for black.
from_rgb() picks whichever is closer in brightness, and every constant except
WHITE becomes 1.
Compile-time and runtime results
to_grayscale() and to_mono() round slightly differently at compile
time and at runtime, so a color near a threshold can differ by a small amount.
blend() works only at compile time, and its arguments must be constants.
Methods
- from_rgb(r, g, b) int
Make a screen color from 0-255 channels.
- Targets:
CE, Classic, Flash App
z = color.from_rgb(x, y, 0)
- to_mono(color) int
0 (white) for a bright color, 1 (black) for a dark one.
- Targets:
CE, Classic, Flash App
z = color.to_mono(x)
- from_mono(mono) int
Screen color for a mono value: 0 white, otherwise black.
- Targets:
CE, Classic, Flash App
z = color.from_mono(x)
- is_valid(color) bool
Whether a value is a valid color.
- Targets:
CE, Classic, Flash App
z = color.is_valid(x)
- invert(color) int
Invert an RGB565 color.
- Targets:
CE, Flash App
- Note:
The classic screen has no RGB colors.
z = color.invert(x)
- to_grayscale(color) int
Convert an RGB565 color to gray.
- Targets:
CE, Flash App
- Note:
The classic screen has no RGB colors.
z = color.to_grayscale(x)
- blend(color1, color2, factor=0.5) int
Blend two constant colors at compile time.
- Targets:
CE
- Note:
The classic screen has no RGB colors.
z = color.blend(color.RED, color.BLUE)
Constants
Constant |
RGB565 value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|