11
11
12
12
"""
13
13
14
+ try :
15
+ from typing import Optional
16
+ except ImportError :
17
+ pass
18
+
14
19
import displayio
15
20
16
21
__version__ = "0.0.0-auto.0"
@@ -35,7 +40,18 @@ class RoundRect(displayio.TileGrid):
35
40
36
41
"""
37
42
38
- def __init__ (self , x , y , width , height , r , * , fill = None , outline = None , stroke = 1 ):
43
+ def __init__ (
44
+ self ,
45
+ x : int ,
46
+ y : int ,
47
+ width : int ,
48
+ height : int ,
49
+ r : int ,
50
+ * ,
51
+ fill : Optional [int ] = None ,
52
+ outline : Optional [int ] = None ,
53
+ stroke : int = 1 ,
54
+ ) -> None :
39
55
self ._palette = displayio .Palette (3 )
40
56
self ._palette .make_transparent (0 )
41
57
self ._bitmap = displayio .Bitmap (width , height , 3 )
@@ -85,17 +101,17 @@ def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1)
85
101
# pylint: disable=invalid-name, too-many-locals, too-many-branches
86
102
def _helper (
87
103
self ,
88
- x0 ,
89
- y0 ,
90
- r ,
104
+ x0 : int ,
105
+ y0 : int ,
106
+ r : int ,
91
107
* ,
92
- color ,
93
- x_offset = 0 ,
94
- y_offset = 0 ,
95
- stroke = 1 ,
96
- corner_flags = 0xF ,
97
- fill = False
98
- ):
108
+ color : int ,
109
+ x_offset : int = 0 ,
110
+ y_offset : int = 0 ,
111
+ stroke : int = 1 ,
112
+ corner_flags : int = 0xF ,
113
+ fill : bool = False ,
114
+ ) -> None :
99
115
f = 1 - r
100
116
ddF_x = 1
101
117
ddF_y = - 2 * r
@@ -142,13 +158,13 @@ def _helper(
142
158
# pylint: enable=invalid-name, too-many-locals, too-many-branches
143
159
144
160
@property
145
- def fill (self ):
161
+ def fill (self ) -> Optional [ int ] :
146
162
"""The fill of the rounded-corner rectangle. Can be a hex value for a color or ``None`` for
147
163
transparent."""
148
164
return self ._palette [2 ]
149
165
150
166
@fill .setter
151
- def fill (self , color ) :
167
+ def fill (self , color : Optional [ int ]) -> None :
152
168
if color is None :
153
169
self ._palette [2 ] = 0
154
170
self ._palette .make_transparent (2 )
@@ -157,13 +173,13 @@ def fill(self, color):
157
173
self ._palette .make_opaque (2 )
158
174
159
175
@property
160
- def outline (self ):
176
+ def outline (self ) -> Optional [ int ] :
161
177
"""The outline of the rounded-corner rectangle. Can be a hex value for a color or ``None``
162
178
for no outline."""
163
179
return self ._palette [1 ]
164
180
165
181
@outline .setter
166
- def outline (self , color ) :
182
+ def outline (self , color : Optional [ int ]) -> None :
167
183
if color is None :
168
184
self ._palette [1 ] = 0
169
185
self ._palette .make_transparent (1 )
0 commit comments