Skip to content

Commit f5ab9c8

Browse files
committed
Merge branch 'adafruit_main' into main
2 parents 37321cc + d05ed7d commit f5ab9c8

12 files changed

+726
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
bitmaptools.fill_region(bitmap, x0, y0, x0 + width, y0 + height, color_index)
57+
else:
58+
rect = vectorio.Rectangle(width, height)
59+
vectorio.VectorShape(
60+
shape=rect,
61+
pixel_shader=palette,
62+
x=x0,
63+
y=y0,
64+
)

0 commit comments

Comments
 (0)