bibliopixel.layout.matrix module

bibliopixel.layout.matrix.LEDMatrix

alias of bibliopixel.layout.matrix.Matrix

class bibliopixel.layout.matrix.Matrix(drivers, width=0, height=0, rotation=0, vert_flip=False, y_flip=False, serpentine=True, threadedUpdate=False, brightness=255, pixelSize=(1, 1), **kwargs)[source]

Bases: bibliopixel.layout.layout.MultiLayout

CLONE_ATTRS = ('maker', 'brightness', 'gen_coord_map', 'coord_map', 'width', 'height', 'rotation', 'vert_flip', 'y_flip', 'serpentine', 'pixelSize')
bresenham_line(x0, y0, x1, y1, color=None, colorFunc=None)[source]

Draw line from point x0, y0 to x1, y1 using Bresenham’s algorithm.

Will draw beyond matrix bounds.

drawChar(x, y, c, color, bg, aa=False, font='8x6', font_scale=1)[source]

Draw a single character c at at (x, y) in an RGB color.

drawCircle(x0, y0, r, color=None)[source]

Draw a circle in an RGB color, with center x0, y0 and radius r.

drawLine(x0, y0, x1, y1, color=None, colorFunc=None, aa=False)[source]

Draw a between x0, y0 and x1, y1 in an RGB color.

Parameters:
  • colorFunc – a function that takes an integer from x0 to x1 and returns a color corresponding to that point
  • aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm
drawRect(x, y, w, h, color=None, aa=False)[source]

Draw rectangle with top-left corner at x,y, width w and height h

Parameters:aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm
drawRoundRect(x, y, w, h, r, color=None, aa=False)[source]

Draw a rounded rectangle with top-left corner at (x, y), width w, height h, and corner radius r

Parameters:aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm
drawText(text, x=0, y=0, color=None, bg=(0, 0, 0), aa=False, font='8x6', font_scale=1)[source]

Draw a line of text starting at (x, y) in an RGB color.

Parameters:
  • colorFunc – a function that takes an integer from x0 to x1 and returns a color corresponding to that point
  • aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm
drawTriangle(x0, y0, x1, y1, x2, y2, color=None, aa=False)[source]

Draw triangle with vertices (x0, y0), (x1, y1) and (x2, y2)

Parameters:aa – if True, use Bresenham’s algorithm for line drawing; Otherwise use Xiaolin Wu’s algorithm
fillCircle(x0, y0, r, color=None)[source]

Draw a filled circle in an RGB color, with center x0, y0 and radius r.

fillRect(x, y, w, h, color=None, aa=False)[source]

Draw a solid rectangle with top-left corner at (x, y), width w and height h.

Parameters:aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm
fillRoundRect(x, y, w, h, r, color=None, aa=False)[source]

Draw a rounded rectangle with top-left corner at (x, y), width w, height h, and corner radius r

Parameters:aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm
fillScreen(color=None)[source]

Fill the matrix with the given RGB color

fillTrangle(x0, y0, x1, y1, x2, y2, color=None, aa=False)

Draw filled triangle with points x0,y0 - x1,y1 - x2,y2

Parameters:aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm
fillTriangle(x0, y0, x1, y1, x2, y2, color=None, aa=False)[source]

Draw filled triangle with points x0,y0 - x1,y1 - x2,y2

Parameters:aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm
get(x, y)[source]

Return the pixel color at position (x, y), or Colors.black if that position is out-of-bounds.

get_pixel_positions()[source]
loadFont(name, height, width, data)[source]
set(x, y, color)[source]

Set the pixel color at position x, y.

setHSV(x, y, hsv)[source]

Set single pixel to HSV tuple

setRGB(x, y, r, g, b)[source]

Set single pixel using individual RGB values instead of tuple

setTexture(tex=None)[source]
shape

Returns width, height

wu_line(x0, y0, x1, y1, color=None, colorFunc=None)[source]

Draw a between x0, y0 and x1, y1 in an RGB color.

Parameters:
  • colorFunc – a function that takes an integer from x0 to x1 and returns a color corresponding to that point
  • aa – if True, use Bresenham’s algorithm for line drawing; otherwise use Xiaolin Wu’s algorithm