summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMat Booth <mat.booth@gmail.com>2022-07-13 21:09:51 +0100
committerDamien George <damien@micropython.org>2022-08-19 23:31:28 +1000
commit04a655c74488128a2c1af9ba8f29fce5e5bbfef9 (patch)
tree78e228b4784ba8b2a7c72175216860a4e2e48d5c /docs
parent42ec9703a07d1d0b55091f5557ff5f81c5134fb8 (diff)
extmod/modframebuf: Add polygon drawing methods.
Add method for drawing polygons. For non-filled polygons, uses the existing line-drawing code to render arbitrary polygons using the given coords list, at the given x,y position, in the given colour. For filled polygons, arbitrary closed polygons are rendered using a fast point-in-polygon algorithm to determine where the edges of the polygon lie on each pixel row. Tests and documentation updates are also included. Signed-off-by: Mat Booth <mat.booth@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/library/framebuf.rst15
1 files changed, 13 insertions, 2 deletions
diff --git a/docs/library/framebuf.rst b/docs/library/framebuf.rst
index 1e23abd0f..78ae0c1c3 100644
--- a/docs/library/framebuf.rst
+++ b/docs/library/framebuf.rst
@@ -11,8 +11,8 @@ class FrameBuffer
-----------------
The FrameBuffer class provides a pixel buffer which can be drawn upon with
-pixels, lines, rectangles, ellipses, text and even other FrameBuffers. It is
-useful when generating output for displays.
+pixels, lines, rectangles, ellipses, polygons, text and even other
+FrameBuffers. It is useful when generating output for displays.
For example::
@@ -98,6 +98,17 @@ The following methods draw shapes onto the FrameBuffer.
to be drawn, with bit 0 specifying Q1, b1 Q2, b2 Q3 and b3 Q4. Quadrants
are numbered counterclockwise with Q1 being top right.
+.. method:: FrameBuffer.poly(x, y, coords, c[, f])
+
+ Given a list of coordinates, draw an arbitrary (convex or concave) closed
+ polygon at the given x, y location using the given color.
+
+ The *coords* must be specified as a :mod:`array` of integers, e.g.
+ ``array('h', [x0, y0, x1, y1, ... xn, yn])``.
+
+ The optional *f* parameter can be set to ``True`` to fill the polygon.
+ Otherwise just a one pixel outline is drawn.
+
Drawing text
------------