Skip to content

Commit

Permalink
adding_circle_drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
jposada202020 committed Feb 10, 2023
1 parent af6f7b1 commit aa7321f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["displayio", "bitmaptools"]
autodoc_mock_imports = ["displayio", "bitmaptools", "vectorio"]

autodoc_preserve_defaults = True

Expand Down
5 changes: 1 addition & 4 deletions examples/uplot_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import time
import board
import displayio
import vectorio
from uplot import Uplot

display = board.DISPLAY
Expand All @@ -16,9 +15,7 @@
palette = displayio.Palette(1)
palette[0] = 0xFFFFFF

circle = vectorio.Circle(pixel_shader=palette, radius=5, x=100, y=100)
plot.append(circle)

plot.draw_circle(radius=8, x=120, y=120)

display.show(plot)
while True:
Expand Down
21 changes: 20 additions & 1 deletion uplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import displayio
from bitmaptools import draw_line
from vectorio import Circle

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

self._axeslinethikness = 1

self._plotbitmap = displayio.Bitmap(self._width, height - 1, 2)

self._axes_palette = displayio.Palette(2)
Expand Down Expand Up @@ -138,6 +141,22 @@ def axes(self, line_color=1):
self._axesybitmap,
pixel_shader=self._axesy_palette,
x=15 - self._axesybitmap_width,
y=self._height - self._axesybitmap_height - self._axesxbitmap_height,
y=self._height
- self._axesybitmap_height
- self._axesxbitmap_height
- self._axeslinethikness
- 2,
)
)

def draw_circle(self, radius=5, x=100, y=100):
"""
Draw a circle in the plot area
:param radius: circle radius
:param x: circles center x coordinate position in pixels, Defaults to 100.
:param y: circles center y coordinate position in pixels. Defaults to 100.
:return: None
"""
palette = displayio.Palette(1)
palette[0] = 0xFFFFFF
self.append(Circle(pixel_shader=palette, radius=radius, x=x, y=y))

0 comments on commit aa7321f

Please sign in to comment.