mirror of
https://github.com/jtgans/g13gui.git
synced 2025-06-20 08:23:50 -04:00
g13gui: bitwidgets: Adding a Rectangle class
So we can draw nice looking rects with curvy corners.
This commit is contained in:
parent
e71d621ff7
commit
95822a273d
27
g13gui/g13gui/bitwidgets/rectangle.py
Normal file
27
g13gui/g13gui/bitwidgets/rectangle.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
from g13gui.bitwidgets.widget import Widget
|
||||||
|
|
||||||
|
|
||||||
|
class Rectangle(Widget):
|
||||||
|
def __init__(self, x, y, w, h, radius=0, fill=True):
|
||||||
|
Widget.__init__(self)
|
||||||
|
self.position = (x, y)
|
||||||
|
self.bounds = (w, h)
|
||||||
|
self.radius = radius
|
||||||
|
self.fill = fill
|
||||||
|
|
||||||
|
def draw(self, ctx):
|
||||||
|
if self._visible:
|
||||||
|
points = (self._position[0], self._position[1],
|
||||||
|
self._position[0] + self._bounds[0],
|
||||||
|
self._position[1] + self._bounds[1])
|
||||||
|
ctx.rounded_rectangle(*points,
|
||||||
|
radius=self._radius,
|
||||||
|
fill=self._fill)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def radius(self):
|
||||||
|
return self._radius
|
||||||
|
|
||||||
|
@radius.setter
|
||||||
|
def radius(self, radius):
|
||||||
|
self._setProperty('radius', radius)
|
Loading…
Reference in New Issue
Block a user