Skip to content

Commit aa7321f

Browse files
committed
adding_circle_drawing
1 parent af6f7b1 commit aa7321f

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Uncomment the below if you use native CircuitPython modules such as
2626
# digitalio, micropython and busio. List the modules you use. Without it, the
2727
# autodoc module docs will fail to generate with a warning.
28-
autodoc_mock_imports = ["displayio", "bitmaptools"]
28+
autodoc_mock_imports = ["displayio", "bitmaptools", "vectorio"]
2929

3030
autodoc_preserve_defaults = True
3131

examples/uplot_simpletest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import time
66
import board
77
import displayio
8-
import vectorio
98
from uplot import Uplot
109

1110
display = board.DISPLAY
@@ -16,9 +15,7 @@
1615
palette = displayio.Palette(1)
1716
palette[0] = 0xFFFFFF
1817

19-
circle = vectorio.Circle(pixel_shader=palette, radius=5, x=100, y=100)
20-
plot.append(circle)
21-
18+
plot.draw_circle(radius=8, x=120, y=120)
2219

2320
display.show(plot)
2421
while True:

uplot.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import displayio
2525
from bitmaptools import draw_line
26+
from vectorio import Circle
2627

2728
__version__ = "0.0.0+auto.0"
2829
__repo__ = "https://github.com/adafruit/CircuitPython_uplot.git"
@@ -44,6 +45,8 @@ def __init__(self, x=0, y=0, width=None, height=None):
4445
self._width = width - 1
4546
self._height = height - 1
4647

48+
self._axeslinethikness = 1
49+
4750
self._plotbitmap = displayio.Bitmap(self._width, height - 1, 2)
4851

4952
self._axes_palette = displayio.Palette(2)
@@ -138,6 +141,22 @@ def axes(self, line_color=1):
138141
self._axesybitmap,
139142
pixel_shader=self._axesy_palette,
140143
x=15 - self._axesybitmap_width,
141-
y=self._height - self._axesybitmap_height - self._axesxbitmap_height,
144+
y=self._height
145+
- self._axesybitmap_height
146+
- self._axesxbitmap_height
147+
- self._axeslinethikness
148+
- 2,
142149
)
143150
)
151+
152+
def draw_circle(self, radius=5, x=100, y=100):
153+
"""
154+
Draw a circle in the plot area
155+
:param radius: circle radius
156+
:param x: circles center x coordinate position in pixels, Defaults to 100.
157+
:param y: circles center y coordinate position in pixels. Defaults to 100.
158+
:return: None
159+
"""
160+
palette = displayio.Palette(1)
161+
palette[0] = 0xFFFFFF
162+
self.append(Circle(pixel_shader=palette, radius=radius, x=x, y=y))

0 commit comments

Comments
 (0)