Class Canvas¶
Defined in File canvas.h
Class Documentation¶
-
class
Canvas
¶ Public Functions
-
Canvas
(Section §ion, uint16_t num_frames = 1)¶ Constructor. This sets the parent Section and the specified number of frames.
-
~Canvas
()¶
-
void
draw_circle
(uint16_t frame_index, uint8_t color_index, uint16_t origin_x, uint16_t origin_y, uint16_t radius, bool fill)¶ Draws a circle.
- Parameters
origin_x
: Center x coordinate.origin_y
: Center y coordinate.radius
: The circle’s radius.fill
: Whether to fill the circle or leave it empty.
-
void
draw_frame
(uint16_t frame_index, uint8_t *frame, uint16_t size_x, uint16_t size_y)¶ Draws an existing frame over the current frame.
- Parameters
frame
: Frame to draw.size_x
: Frame width.size_y
: Frame height.
-
void
draw_line
(uint16_t frame_index, uint8_t color_index, uint16_t origin_x, uint16_t origin_y, uint16_t target_x, uint16_t target_y)¶ Draws a line.
- Parameters
cursor_x
: Starting point x coordinate.cursor_y
: Starting point y coordinate.target_x
: Ending point x coordinate.target_y
: Ending point y coordinate.
-
void
draw_point
(uint16_t frame_index, uint8_t color_index, uint16_t x, uint16_t y)¶ Enables the pixel at the specified coordinates.
- Parameters
cursor_x
: Starting point x coordinate.cursor_y
: Starting point y coordinate.
-
void
draw_rect
(uint16_t frame_index, uint8_t color_index, uint16_t origin_x, uint16_t origin_y, uint16_t size_x, uint16_t size_y, bool fill)¶ Draws a rectangle.
- Parameters
origin_x
: Top-left corner x coordinate.origin_y
: Top-left corner y coordinate.size_x
: Width of the rectangle.size_y
: Height of the rectangle.fill
: Whether to fill the rectangle or leave it empty.
-
void
draw_text
(uint16_t frame_index, uint8_t color_index, uint16_t origin_x, uint16_t origin_y, Font &font, const char *text, uint8_t num_chars)¶ Draws a string of characters.
- Parameters
origin_x
: Top-left x coordinate.origin_y
: Top-left y coordinate.font
: The Font to draw the text in.text
: The string to draw.
-
void
draw_triangle
(uint16_t frame_index, uint8_t color_index, uint16_t point_a_x, uint16_t point_a_y, uint16_t point_b_x, uint16_t point_b_y, uint16_t point_c_x, uint16_t point_c_y, bool fill)¶ Draws a triangle. Points are drawn in a clockwise manner.
- Parameters
point_a_x
: First point x-coordinate.point_a_y
: First point y-coordinate.point_b_x
: Second point x-coordinate.point_b_y
: Second point y-coordinate.point_c_x
: Third point x-coordinate.point_c_y
: Third point y-coordinate.fill
: Whether to fill the triangle or leave it empty.
-
void
erase_point
(uint16_t frame_index, uint16_t x, uint16_t y)¶ Sets the color of the pixel at the specified index to transparent.
- Parameters
x
: X coordinate.y
: Y coordinate.
-
uint16_t
get_current_frame_index
() const¶ Returns the index of the current frame.
- Return
Current frame index.
-
Timer *
get_frame_timer
() const¶ Returns the frame timer. Used in PixelMaestro Studio.
- Return
Frame timer.
-
uint8_t *
get_frame
(uint16_t frame) const¶ Returns the frame at the specified index.
- Return
Frame at index.
- Parameters
frame
: Index of the frame.
-
uint16_t
get_num_frames
() const¶ Returns the number of frames.
- Return
Number of frames.
-
void
next_frame
()¶ Advances the animation to the next frame. If we’ve hit the total number of frames, wrap back to the first frame.
-
void
previous_frame
()¶ Moves the animation back a frame. If we’ve hit the first frame, jump to the last frame.
-
void
remove_frame_timer
()¶ Removes the frame timer, disabling frame animations.
-
void
set_current_frame_index
(uint16_t index)¶ Changes the active frame.
- Parameters
index
: Index of the new frame.
-
void
set_frame_timer
(uint16_t speed)¶ Sets the amount of time between frames.
- Parameters
speed
: Amount of time between frames.
-