1111
1212"""
1313
14+ try :
15+ from typing import Optional
16+ except ImportError :
17+ pass
18+
1419import displayio
1520
1621__version__ = "0.0.0-auto.0"
@@ -35,7 +40,18 @@ class RoundRect(displayio.TileGrid):
3540
3641 """
3742
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 :
3955 self ._palette = displayio .Palette (3 )
4056 self ._palette .make_transparent (0 )
4157 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)
85101 # pylint: disable=invalid-name, too-many-locals, too-many-branches
86102 def _helper (
87103 self ,
88- x0 ,
89- y0 ,
90- r ,
104+ x0 : int ,
105+ y0 : int ,
106+ r : int ,
91107 * ,
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 :
99115 f = 1 - r
100116 ddF_x = 1
101117 ddF_y = - 2 * r
@@ -142,13 +158,13 @@ def _helper(
142158 # pylint: enable=invalid-name, too-many-locals, too-many-branches
143159
144160 @property
145- def fill (self ):
161+ def fill (self ) -> Optional [ int ] :
146162 """The fill of the rounded-corner rectangle. Can be a hex value for a color or ``None`` for
147163 transparent."""
148164 return self ._palette [2 ]
149165
150166 @fill .setter
151- def fill (self , color ) :
167+ def fill (self , color : Optional [ int ]) -> None :
152168 if color is None :
153169 self ._palette [2 ] = 0
154170 self ._palette .make_transparent (2 )
@@ -157,13 +173,13 @@ def fill(self, color):
157173 self ._palette .make_opaque (2 )
158174
159175 @property
160- def outline (self ):
176+ def outline (self ) -> Optional [ int ] :
161177 """The outline of the rounded-corner rectangle. Can be a hex value for a color or ``None``
162178 for no outline."""
163179 return self ._palette [1 ]
164180
165181 @outline .setter
166- def outline (self , color ) :
182+ def outline (self , color : Optional [ int ]) -> None :
167183 if color is None :
168184 self ._palette [1 ] = 0
169185 self ._palette .make_transparent (1 )
0 commit comments