TFT_eSPI provides a rich set of primitive drawing functions that cover everything from a single pixel to filled gradient rectangles. All coordinates use a top-left origin — the X-axis increases to the right and the Y-axis increases downward. Outline functions draw the border of a shape, while theirDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Marcussacapuces91/doc-TFT_eSPI/llms.txt
Use this file to discover all available pages before exploring further.
fill counterparts flood the interior with a solid color. Choosing the right primitive keeps your rendering fast and your code readable.
Coordinate System
The display origin(0, 0) is the top-left corner. Coordinates and dimensions are always expressed in pixels. Every drawing call clips automatically to the active viewport, so out-of-bounds coordinates are safe.
All color values are 16-bit RGB565 unless otherwise noted. TFT_eSPI ships with named constants such as
TFT_RED, TFT_GREEN, TFT_BLUE, TFT_WHITE, TFT_BLACK, and many more.Pixels
drawPixel
Push a single pixel to the display, with optional alpha-blending against a background color.
X coordinate of the pixel.
Y coordinate of the pixel.
Pixel color (RGB565).
Alpha blend value
0 (transparent) to 255 (opaque). Only used in the blending overload.Background color to blend against. Defaults to
0x00FFFFFF, which instructs the library to read the actual pixel from the display.uint16_t pixel color after blending is applied.
Lines
drawLine
Draw a line between two arbitrary points using Bresenham’s algorithm.
Start X coordinate.
Start Y coordinate.
End X coordinate.
End Y coordinate.
Line color (RGB565).
drawFastHLine and drawFastVLine
Optimized routines for axis-aligned lines. These are considerably faster than drawLine for horizontal and vertical segments.
Starting X coordinate.
Starting Y coordinate.
drawFastHLine — width (number of pixels to the right).drawFastVLine — height (number of pixels downward).Line color.
Rectangles
drawRect and drawRoundRect
Draw a rectangle outline or a rounded-corner rectangle outline.
X coordinate of the top-left corner.
Y coordinate of the top-left corner.
Width in pixels.
Height in pixels.
Corner radius in pixels (
drawRoundRect only).Border color.
fillRect and fillRoundRect
Filled counterparts of the outline functions above.
color sets the fill color.
fillScreen
Fill the entire display with a single color — the fastest way to clear the screen.
Fill color.
Circles
drawCircle and fillCircle
Draw or fill a circle using the optimized midpoint circle algorithm.
X coordinate of the center.
Y coordinate of the center.
Radius in pixels.
Outline or fill color.
Ellipses
drawEllipse and fillEllipse
Draw or fill an ellipse with independent horizontal and vertical radii.
X coordinate of the center.
Y coordinate of the center.
Horizontal radius in pixels.
Vertical radius in pixels.
Outline or fill color.
Triangles
drawTriangle and fillTriangle
Draw or fill an arbitrary triangle defined by three vertices.
First vertex coordinates.
Second vertex coordinates.
Third vertex coordinates.
Outline or fill color.
Gradient Fills
fillRectVGradient and fillRectHGradient
Fill a rectangle with a smooth color gradient — either vertical (top-to-bottom) or horizontal (left-to-right).
X coordinate of the top-left corner.
Y coordinate of the top-left corner.
Width in pixels.
Height in pixels.
Start color (top or left).
End color (bottom or right).
Practical Example
The following sketch draws a small scene that combines most of the primitives covered above.TFT_BROWN and TFT_DARKGREEN may not be defined in all TFT_eSPI builds. Replace them with tft.color565(r, g, b) calls if needed, e.g. tft.color565(139, 69, 19) for brown.