Tree
Contains all the methods you need to change the tree. (Where the magic happens)
Tree()
This is a class which holds the tree data, it shouldn't be used directly
init(tree_file)
For internal use Initialise / reset the tree
height()
The height of the tree
Examples:
if pixel.z < height() / 2: pixel.set_rgb(255, 255, 255)
num_pixels()
The number of pixels, equivelant to len(pixels()) but faster
pixels(n=None)
The main way of accessing pixels
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Optional[int]
|
Grab only the nth pixel |
None
|
Examples:
for pixel in pixels(): pixel.set_rgb(255, 255, 255)
for i in range(num_pixels()): pixels(i).set_rgb(255, 255, 255)
set_pixel(n, color)
set_fps(fps)
fade(n=10)
background(c)
fill(color)
Set all lights on the tree to one color
This differs from background as it is part of the 1st rendering layer, directly setting pixels
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
Color
|
The color you want to set the tree to |
required |
lerp(color, frames, fn=linear)
Lerp the entire tree from its current color to the target color over the specified amount of frames
Once lerp has been called, it will automatically interpolate every frame to the target. Subsequent calls with the same parameters will continue the lerp, not reset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
Color
|
Target color |
required |
frames
|
int
|
The number of frames to perform the lerp over |
required |
fn
|
Callable[[float], float]
|
Timing function from the Util module. Defaults to linear. |
linear
|
coords()
An array of 3d coordinates mapped directly to the pixels coords()[10] gives the xyz tuple of the 10th pixel in the strip equivelant to pixels(10).xyz
frame()
seconds()
The number of seconds since the start of the pattern