Skip to content

Commit 057a96c

Browse files
committed
# TODO Replace with drawline/vectorio [X]
# TODO Make a rectangle function [ ] # TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ]
1 parent 7f4e1b1 commit 057a96c

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

adafruit_displayio_layout/widgets/cartesian.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
# pylint: disable=too-many-lines, too-many-instance-attributes, too-many-arguments
2525
# pylint: disable=too-many-locals, too-many-statements
2626

27-
import math
2827
import displayio
2928
import board
3029
import terminalio
@@ -80,12 +79,13 @@ def __init__(
8079
**kwargs,
8180
) -> None:
8281
# TODO Make axes, separate from data [X]
83-
# TODO Replace with drawline/vectorio [ ]
82+
# TODO Replace with drawline/vectorio [X]
8483
# TODO Make a rectangle function [ ]
8584
# TODO Include functions to equal space ticks [ ]
8685
# TODO Make labels and text [ ]
8786
# TODO Make Styles applicable [ ]
8887
# TODO Animate when overflow [ ]
88+
# TODO Add Subticks functionality [ ]
8989

9090
super().__init__(**kwargs, max_size=3)
9191
self._origin_x = x
@@ -205,28 +205,19 @@ def _draw_axes(self):
205205

206206
def _draw_ticks(self):
207207
for i in range(self._margin, self._usable_width, self._tickx_separation):
208-
if "rotozoom" in dir(bitmaptools): # if core function is available
209-
bitmaptools.rotozoom(
210-
self._screen_bitmap,
211-
ox=i,
212-
oy=self._usable_height + self._tick_line_height // 2,
213-
source_bitmap=self._tick_bitmap,
214-
px=int(self._tick_bitmap.width),
215-
py=self._tick_bitmap.height,
216-
angle=0.0, # in radians
217-
)
208+
bitmaptools.draw_line(
209+
self._axesx_bitmap, i, self._tick_line_height // 2, i, 0, 2
210+
)
218211

219212
for i in range(self._margin, self._usable_height, self._tickx_separation):
220-
if "rotozoom" in dir(bitmaptools): # if core function is available
221-
bitmaptools.rotozoom(
222-
self._screen_bitmap,
223-
ox=0,
224-
oy=i,
225-
source_bitmap=self._tick_bitmap,
226-
px=int(self._tick_bitmap.width),
227-
py=int(self._tick_bitmap.height / 2),
228-
angle=(90 * math.pi / 180), # in radians
229-
)
213+
bitmaptools.draw_line(
214+
self._axesy_bitmap,
215+
(self._axesy_width - self._tick_line_height // 2) - 1,
216+
i,
217+
self._axesy_width - 1,
218+
i,
219+
2,
220+
)
230221

231222
def _draw_pointers(self):
232223
self._pointer = vectorio.Circle(3)

examples/displayio_layout_cartesian_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# for display chip driver and pinout you have (e.g. ILI9341)
2121

2222

23-
# Create a Dial widget
23+
# Create a Cartesian widget
2424
my_plane = Cartesian(
2525
x=150, # x position for the plane
2626
y=100, # y plane position

0 commit comments

Comments
 (0)