class documentation

Class for drawing shapes and text on the display.

Methods

char(position, char, color=None, font_size=-1)
Draw a single character
circle(position, radius, color=None)
Draw a circle outline
clear(position=Vector(0, 0), size=Vector(320, 320), color=None)
Fill a rectangular area with a color
`erase`()
Clear the entire display
fill_circle(position, radius, color=None)
Draw a filled circle
fill_rectangle(position, size, color=None)
Draw a filled rectangle
fill_round_rectangle(position, size, radius, color=None)
Draw a filled rounded rectangle
fill_screen(color=None)
Fill the entire screen with a color
fill_triangle(point1, point2, point3, color=None)
Draw a filled triangle
fill_triangle_alpha(point1, point2, point3, color=None, alpha=255)
Draw a filled triangle with alpha blending
get_font(font_size=0)
Get the FontSize object for a given font size
image(position, img)
Draw an image object to the back buffer
image_bmp(position, path, storage=None)
Draw a 24-bit BMP image from a file path
image_jpeg(position, path, storage=None)
Draw a JPEG image from a file path
image_jpeg_buffer(position, buf)
Draw a JPEG image from bytes data in a buffer
image_bytearray(position, size, byte_data, invert=False)
Draw an image from 8-bit byte data (bytes or bytearray)
image_bytearray_1bit(position, size, byte_data)
Draw a 1-bit bitmap from packed byte_data (8 pixels per byte, row-aligned)
image_bytearray_path(position, size, path, storage=None, seek=0, chunk_size=0, mount_vfs=True)
Draw an image from an 8-bit bytearray file stored on disk
len(text, font_size=0)
Calculate the pixel width of a text string for a given font size
line(position, size, color=None)
Draw a horizontal line
line_custom(point_1, point_2, color=None)
Draw a line between two points
pixel(position, color=None)
Draw a single pixel
psram(position, size, addr)
Draw pixel data directly from PSRAM at the specified address and length
rect(position, size, color=None)
Draw a rectangle outline
screenshot(file_path)
Take a screenshot of the current display and save it to the specified file path (.bmp)
set_brightness(level)
Set the display brightness (0-100)
set_mode(mode)
Set the LCD mode (PSRAM or HEAP)
set_scaling(scale_x, scale_y, scale_position=False)
Set the LCD scaling parameters
`swap`()
Update the display with the current framebuffer contents
text(position, text, color=None, font_size=-1)
Draw text on the display
triangle(point1, point2, point3, color=None)
Draw a triangle outline
Method __del__ Destructor to ensure cleanup on object deletion
Method __init__ Initialize the drawing context with colors and scaling.
Method background.setter Set the current background color.
Method char Draw a single character on the display.
Method circle Draw a circle outline.
Method clear Fill a rectangular area with a color.
Method erase Erase the display by filling with background color
Method fill_circle Draw a filled circle.
Method fill_rectangle Draw a filled rectangle.
Method fill_round_rectangle Draw a filled rounded rectangle on the display.
Method fill_screen Fill the entire screen with a color.
Method fill_triangle Draw a filled triangle.
Method fill_triangle_alpha Draw a filled triangle with alpha blending.
Method font.setter Set the default font size.
Method foreground.setter Set the current foreground color.
Method get_font Get the FontSize object for the specified font size.
Method image Draw an image object to the back buffer.
Method image_bmp Draw a 24-bit BMP image.
Method image_bytearray Draw an image from 8-bit byte data (bytes or bytearray).
Method image_bytearray_1bit Draw a 1-bit bitmap from packed byte_data (8 pixels per byte, row-aligned).
Method image_bytearray_path Draw an image from an 8-bit bytearray file stored on disk.
Method image_jpeg Draw a JPEG image from a file path.
Method image_jpeg_buffer Draw a JPEG image from bytes data into a BytesIO buffer.
Method len Calculate the pixel width of a text string for a given font size.
Method line Draw horizontal line.
Method line_custom Draw line between two points.
Method pixel Draw a pixel.
Method psram Draw pixel data directly from PSRAM at the specified address and length.
Method rect Draw a rectangle outline on the display.
Method text Draw text on the display.
Method triangle Draw a triangle outline.
Method use_lvgl.setter Set whether to use LVGL mode for drawing.
Property background Get the current background color
Property font Get the default font size
Property font_size Get the font size
Property foreground Get the current foreground color
Property size Get the size of the display
Property use_lvgl Get whether LVGL mode is enabled
Instance Variable _background Undocumented
Instance Variable _font_default Undocumented
Instance Variable _font_size Undocumented
Instance Variable _foreground Undocumented
Instance Variable _size Undocumented
Instance Variable _use_lvgl Undocumented
def __del__(self):

Destructor to ensure cleanup on object deletion

def __init__(self, foreground: int = 65535, background: int = 0, scale_x: float = 1.0, scale_y: float = 1.0, scale_position: bool = False):

Initialize the drawing context with colors and scaling.

Parameters
foreground:intThe default color for drawing. Defaults to 0xFFFF.
background:intThe default color for clearing. Defaults to 0x0000.
scale_x:floatHorizontal scaling factor for drawing operations. Defaults to 1.0.
scale_y:floatVertical scaling factor for drawing operations. Defaults to 1.0.
scale_position:boolWhether to scale drawn element positions. Defaults to False.
def background(self, color: int):

Set the current background color.

Parameters
color:intThe new background color.
def char(self, position: Vector, char: str, color=None, font_size: int = -1):

Draw a single character on the display.

Parameters
position:VectorThe position to draw the character.
char:strThe character to draw.
color:intThe color to use. Defaults to None (foreground).
font_size:intThe font size to use. Defaults to -1 (default font).
def circle(self, position: Vector, radius: int, color: int = None):

Draw a circle outline.

Parameters
position:VectorThe center position of the circle.
radius:intThe radius of the circle.
color:intThe color to use. Defaults to None (foreground).
def clear(self, position: Vector = Vector(0, 0), size: Vector = Vector(320, 320), color=None):

Fill a rectangular area with a color.

Parameters
position:VectorThe top-left corner of the area. Defaults to Vector(0, 0).
size:VectorThe size of the area. Defaults to Vector(320, 320).
color:intThe fill color. Defaults to None (background).
def erase(self):

Erase the display by filling with background color

def fill_circle(self, position: Vector, radius: int, color=None):

Draw a filled circle.

Parameters
position:VectorThe center position of the circle.
radius:intThe radius of the circle.
color:intThe fill color. Defaults to None (foreground).
def fill_rectangle(self, position: Vector, size: Vector, color=None):

Draw a filled rectangle.

Parameters
position:VectorThe top-left corner of the rectangle.
size:VectorThe size of the rectangle.
color:intThe fill color. Defaults to None (foreground).
def fill_round_rectangle(self, position: Vector, size: Vector, radius: int, color=None):

Draw a filled rounded rectangle on the display.

Parameters
position:VectorThe top-left corner of the rectangle.
size:VectorThe size of the rectangle.
radius:intThe corner radius.
color:intThe fill color. Defaults to None (foreground).
def fill_screen(self, color=None):

Fill the entire screen with a color.

Parameters
color:intThe fill color. Defaults to None (background).
def fill_triangle(self, point1: Vector, point2: Vector, point3: Vector, color=None):

Draw a filled triangle.

Parameters
point1:VectorFirst vertex of the triangle.
point2:VectorSecond vertex of the triangle.
point3:VectorThird vertex of the triangle.
color:intThe fill color. Defaults to None (foreground).
def fill_triangle_alpha(self, point1: Vector, point2: Vector, point3: Vector, color=None, alpha: int = 255):

Draw a filled triangle with alpha blending.

Parameters
point1:VectorFirst vertex of the triangle.
point2:VectorSecond vertex of the triangle.
point3:VectorThird vertex of the triangle.
color:intThe fill color. Defaults to None (foreground).
alpha:intThe alpha value for blending. Defaults to 255.
def font(self, font_size: int):

Set the default font size.

Parameters
font_size:intThe new default font size.
def foreground(self, color: int):

Set the current foreground color.

Parameters
color:intThe new foreground color.
def get_font(self, font_size: int = 0):

Get the FontSize object for the specified font size.

Parameters
font_size:intThe font size to look up. Defaults to 0.
Returns
FontSizeThe FontSize object for the given size.
def image(self, position: Vector, img):

Draw an image object to the back buffer.

Parameters
position:VectorThe top-left position to draw the image.
img:ImageThe image object to draw.
def image_bmp(self, position: Vector, path: str):

Draw a 24-bit BMP image.

Parameters
position:VectorThe top-left position to draw the image.
path:strThe path to the BMP file.
def image_bytearray(self, position: Vector, size: Vector, byte_data, invert: bool = False):

Draw an image from 8-bit byte data (bytes or bytearray).

Parameters
position:VectorThe top-left position to draw the image.
size:VectorThe size of the image.
byte_dataThe pixel data as bytes or bytearray.
invert:boolWhether to invert the pixel values. Defaults to False.
def image_bytearray_1bit(self, position: Vector, size: Vector, byte_data, invert: bool = False):

Draw a 1-bit bitmap from packed byte_data (8 pixels per byte, row-aligned).

Parameters
position:VectorThe top-left position to draw the image.
size:VectorThe size of the image.
byte_dataPacked 1-bit pixel data.
invert:boolWhether to invert the pixel values. Defaults to False.
def image_bytearray_path(self, position: Vector, size: Vector, path: str, storage=None, seek=0, chunk_size=0, invert=False):

Draw an image from an 8-bit bytearray file stored on disk.

Parameters
position:VectorThe top-left position to draw the image.
size:VectorThe size of the image.
path:strThe path to the bytearray file.
storageStorage instance for file access. Defaults to None.
seek:intByte offset to start reading from. Defaults to 0.
chunk_size:intNumber of bytes to read per chunk. Defaults to 0 (read all).
invert:boolWhether to invert the pixel values. Defaults to False.
def image_jpeg(self, position: Vector, path: str, storage=None) -> bool:

Draw a JPEG image from a file path.

Parameters
position:VectorThe top-left position to draw the image.
path:strThe path to the JPEG file.
storageStorage instance for file access. Defaults to None.
Returns
boolTrue on success, False on failure.
def image_jpeg_buffer(self, position: Vector, buf) -> bool:

Draw a JPEG image from bytes data into a BytesIO buffer.

Parameters
position:VectorThe top-left position to draw the image.
bufBytes data containing the JPEG image.
Returns
boolTrue on success, False on failure.
def len(self, text: str, font_size: int = 0) -> int:

Calculate the pixel width of a text string for a given font size.

Parameters
text:strThe text to measure.
font_size:intThe font size to use. Defaults to 0.
Returns
intThe pixel width of the text.
def line(self, position: Vector, size: Vector, color=None):

Draw horizontal line.

Parameters
position:VectorThe starting position of the line.
size:VectorThe size of the line.
color:intThe line color. Defaults to None (foreground).
def line_custom(self, point_1: Vector, point_2: Vector, color=None):

Draw line between two points.

Parameters
point_1:VectorThe first point.
point_2:VectorThe second point.
color:intThe line color. Defaults to None (foreground).
def pixel(self, position: Vector, color=None):

Draw a pixel.

Parameters
position:VectorThe position of the pixel.
color:intThe pixel color. Defaults to None (foreground).
def psram(self, position: Vector, size: Vector, addr: int):

Draw pixel data directly from PSRAM at the specified address and length.

Parameters
position:VectorThe top-left position to draw the data.
size:VectorThe size of the image data.
addr:intThe PSRAM address to read from.
def rect(self, position: Vector, size: Vector, color=None):

Draw a rectangle outline on the display.

Parameters
position:VectorThe top-left corner of the rectangle.
size:VectorThe size of the rectangle.
color:intThe outline color. Defaults to None (foreground).
def text(self, position: Vector, text: str, color=None, font_size: int = -1):

Draw text on the display.

Parameters
position:VectorThe position to draw the text.
text:strThe text to draw.
color:intThe text color. Defaults to None (foreground).
font_size:intThe font size to use. Defaults to -1 (default font).
def triangle(self, point1: Vector, point2: Vector, point3: Vector, color=None):

Draw a triangle outline.

Parameters
point1:VectorFirst vertex of the triangle.
point2:VectorSecond vertex of the triangle.
point3:VectorThird vertex of the triangle.
color:intThe outline color. Defaults to None (foreground).
def use_lvgl(self, state: bool):

Set whether to use LVGL mode for drawing.

Parameters
state:boolTrue to enable LVGL mode.
@property
background: int =

Get the current background color

@property
font: int =

Get the default font size

@property
font_size: Vector =

Get the font size

@property
foreground: int =

Get the current foreground color

@property
size: Vector =

Get the size of the display

@property
use_lvgl: bool =

Get whether LVGL mode is enabled

_background =

Undocumented

_font_default =

Undocumented

_font_size =

Undocumented

_foreground =

Undocumented

_size =

Undocumented

_use_lvgl =

Undocumented