# Path: flexlay/math/rect.py
# class Rectf(Rect):
# 
#     def __init__(self, arg1=None, arg2=None, arg3=None, arg4=None):
#         super().__init__()
# 
#         if arg1 is None and arg2 is None and arg3 is None and arg4 is None:
#             self.left = 0.0
#             self.top = 0.0
#             self.right = 0.0
#             self.bottom = 0.0
#         elif arg2 is None and arg3 is None and arg4 is None:
#             self.left = arg1.left
#             self.top = arg1.top
#             self.right = arg1.right
#             self.bottom = arg1.bottom
#         elif arg3 is None and arg4 is None:
#             self.left = arg1.x
#             self.top = arg1.y
#             self.right = arg1.x + arg2.width
#             self.bottom = arg1.y + arg2.height
#         else:
#             self.left = arg1
#             self.top = arg2
#             self.right = arg3
#             self.bottom = arg4


from PyQt5.QtCore import QLineF
from PyQt5.QtGui import QPainterPath
from flexlay.math import Rectf





class GraphicContext:

    def __init__(self, painter, state=None):
        self.painter = painter
        self.state = state

    def clear(self, color):
        pass  # GRUMBEL gc.clear(color)

    def draw_rect(self, rect, color, radius=0):
        if radius == 0:
            self.painter.setPen(color.to_qt())
            self.painter.drawRect(rect.to_qt())
            return

        self.painter.setPen(color.to_qt())
        self.painter.drawRoundedRect(rect.to_qt(), radius, radius)

    def fill_rect(self, rect, color, radius=0):
        if radius == 0:
            self.painter.fillRect(rect.to_qt(), color.to_qt())
            return

        path = QPainterPath()
        path.addRoundedRect(rect.to_qt_f(), radius, radius)

# Path: flexlay/math/rect.py
# class Rectf(Rect):
# 
#     def __init__(self, arg1=None, arg2=None, arg3=None, arg4=None):
#         super().__init__()
# 
#         if arg1 is None and arg2 is None and arg3 is None and arg4 is None:
#             self.left = 0.0
#             self.top = 0.0
#             self.right = 0.0
#             self.bottom = 0.0
#         elif arg2 is None and arg3 is None and arg4 is None:
#             self.left = arg1.left
#             self.top = arg1.top
#             self.right = arg1.right
#             self.bottom = arg1.bottom
#         elif arg3 is None and arg4 is None:
#             self.left = arg1.x
#             self.top = arg1.y
#             self.right = arg1.x + arg2.width
#             self.bottom = arg1.y + arg2.height
#         else:
#             self.left = arg1
#             self.top = arg2
#             self.right = arg3
#             self.bottom = arg4


# Path: flexlay/graphic_context.py
from PyQt5.QtCore import QLineF
from PyQt5.QtGui import QPainterPath
from flexlay.math import Rectf






class GraphicContext:

    def __init__(self, painter, state=None):
        self.painter = painter
        self.state = state

    def clear(self, color):
        pass  # GRUMBEL gc.clear(color)

    def draw_rect(self, rect, color, radius=0):
        if radius == 0:
            self.painter.setPen(color.to_qt())
            self.painter.drawRect(rect.to_qt())
            return

        self.painter.setPen(color.to_qt())
        self.painter.drawRoundedRect(rect.to_qt(), radius, radius)

    def fill_rect(self, rect, color, radius=0):
        if radius == 0:
            self.painter.fillRect(rect.to_qt(), color.to_qt())
            return

        path = QPainterPath()
        path.addRoundedRect(rect.to_qt_f(), radius, radius)

        self.painter.fillPath(path, color.to_qt())