Skip to content

Commit 185e539

Browse files
committed
# 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 057a96c commit 185e539

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# SPDX-FileCopyrightText: 2021 Kevin Matocha, Tim C, Jose David M
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
"""
6+
`adafruit_displayio_layout.widgets`
7+
=======================
8+
"""
9+
10+
import vectorio
11+
12+
try:
13+
import bitmaptools
14+
except NameError:
15+
pass
16+
17+
18+
# pylint: disable=invalid-name, too-many-arguments
19+
def rectangle_helper(
20+
x0: int,
21+
y0: int,
22+
height: int,
23+
width: int,
24+
bitmap,
25+
color_index: int,
26+
palette,
27+
bitmaptool: bool = True,
28+
) -> None:
29+
"""rectangle_helper function
30+
Draws a rectangle to the bitmap given using ``bitmapstools.bitmap`` or
31+
``vectorio.rectangle`` functions
32+
33+
:param int x0: rectangle lower corner x position
34+
:param int y0: rectangle lower corner y position
35+
36+
:param int width: rectangle upper corner x position
37+
:param int height: rectangle upper corner y position
38+
39+
:param int color_index: palette color index to be used
40+
:param palette: palette object to be used to draw the rectangle
41+
42+
:param bitmap: bitmap for the rectangle to be drawn
43+
:param bool bitmaptool: uses :py:func:`~bitmaptools.draw_line` to draw the rectanlge.
44+
when `False` uses :py:func:`~vectorio.Rectangle`
45+
46+
:return: None
47+
:rtype: None
48+
49+
┌───────────────────────┐
50+
│ │
51+
│ │
52+
(x0,y0) └───────────────────────┘
53+
54+
"""
55+
if bitmaptool:
56+
x1 = x0 + width
57+
y1 = y0 + height
58+
for row_pos in range(y0, y1, 1):
59+
bitmaptools.draw_line(bitmap, x0, row_pos, x1, row_pos, color_index)
60+
else:
61+
rect = vectorio.Rectangle(width, height)
62+
vectorio.VectorShape(
63+
shape=rect,
64+
pixel_shader=palette,
65+
x=x0,
66+
y=y0,
67+
)

adafruit_displayio_layout/widgets/cartesian.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,15 @@ def __init__(
7878
pointer_color: int = 0xFFFFFF,
7979
**kwargs,
8080
) -> None:
81-
# TODO Make axes, separate from data [X]
82-
# TODO Replace with drawline/vectorio [X]
83-
# TODO Make a rectangle function [ ]
81+
# TODO Make axes, separate from data []
82+
# TODO Replace with drawline/vectorio []
83+
# TODO Make a rectangle function []
8484
# TODO Include functions to equal space ticks [ ]
8585
# TODO Make labels and text [ ]
8686
# TODO Make Styles applicable [ ]
8787
# TODO Animate when overflow [ ]
8888
# TODO Add Subticks functionality [ ]
89+
# TODO ticks evenly distributed [ ]
8990

9091
super().__init__(**kwargs, max_size=3)
9192
self._origin_x = x

0 commit comments

Comments
 (0)