gfx

CircuitPython pixel graphics drawing library.

  • Author(s): Kattni Rembor, Tony DiCola, Jonah Yolles-Murphy, based on code by Phil Burgess

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_gfx.gfx.GFX(width, height, pixel, hline=None, vline=None, fill_rect=None, text=None, font=None)

Create an instance of the GFX drawing class.

Parameters:
  • width – The width of the drawing area in pixels.
  • height – The height of the drawing area in pixels.
  • pixel – A function to call when a pixel is drawn on the display. This function should take at least an x and y position and then any number of optional color or other parameters.
  • hline – A function to quickly draw a horizontal line on the display. This should take at least an x, y, and width parameter and any number of optional color or other parameters.
  • vline – A function to quickly draw a vertical line on the display. This should take at least an x, y, and height paraemter and any number of optional color or other parameters.
  • fill_rect – A function to quickly draw a solid rectangle with four input parameters: x,y, width, and height. Any number of other parameters for color or screen specific data.
  • text – A function to quickly place text on the screen. The inputs include: x, y data(top left as starting point).
  • font – An optional input to augment the default text method with a new font. The input should be a properly formatted dict.
circle(x0, y0, radius, *args, **kwargs)

Circle drawing function. Will draw a single pixel wide circle with center at x0, y0 and the specified radius.

fill_circle(x0, y0, radius, *args, **kwargs)

Filled circle drawing function. Will draw a filled circle with center at x0, y0 and the specified radius.

fill_round_rect(x0, y0, width, height, radius, *args, **kwargs)

Filled circle drawing function. Will draw a filled circle with center at x0, y0 and the specified radius.

fill_triangle(x0, y0, x1, y1, x2, y2, *args, **kwargs)

Filled triangle drawing function. Will draw a filled triangle around the points (x0, y0), (x1, y1), and (x2, y2).

line(x0, y0, x1, y1, *args, **kwargs)

Line drawing function. Will draw a single pixel wide line starting at x0, y0 and ending at x1, y1.

pixel(x0, y0, *args, **kwargs)

A function to pass through in input pixel functionality.

rect(x0, y0, width, height, *args, **kwargs)

Rectangle drawing function. Will draw a single pixel wide rectangle starting in the upper left x0, y0 position and width, height pixels in size.

round_rect(x0, y0, width, height, radius, *args, **kwargs)

Rectangle with rounded corners drawing function. This works like a regular rect though! if radius = 0 Will draw the outline of a rectangle with rounded corners with (x0,y0) at the top left

set_text_background(*args, **kwargs)

A function to change the background color of text, input any and all color params. Run without any inputs to return to “clear” background

triangle(x0, y0, x1, y1, x2, y2, *args, **kwargs)

Triangle drawing function. Will draw a single pixel wide triangle around the points (x0, y0), (x1, y1), and (x2, y2).

gfx_standard_font_01

CircuitPython pixel graphics drawing library.

  • Author(s): Jonah Yolles-Murphy

Implementation Notes

Hardware:

Software and Dependencies:

  • Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
  • letter format:
    { ‘character_here’ : bytearray(WIDTH,HEIGHT,right-most-data,more-bytes-here,left-most-data’)} the right most bit is the top most bit of each vertical stripe of a char
  • Key format:
    keys of one length only represent one character. longer then one is either extended characters or special characters like the degree sign. all extended or special charaters have all capitalized keys. “?CHAR?” is used when an input character is not in the font dictionary