from __future__ import annotations
from ..function import *
import math
from .types import *

class draw:
    @staticmethod
    def rect(window: Surface, tex: Texture, rect: Rect, color: RGBA=RGBA(255,255,255,255)):
        if window.type == SurfaceType.WINDOW:
            lib.draw_rect_win(window._id, rect.x, rect.y, rect.w, rect.h, color.r / 255.0, color.g / 255.0, color.b / 255.0, color.a / 255.0)
        elif window.type == SurfaceType.TEXTURE:
            lib.draw_rect_tex(window._id, rect.x, rect.y, rect.w, rect.h, color.r / 255.0, color.g / 255.0, color.b / 255.0, color.a / 255.0)

    @staticmethod   
    def texture(window: Surface, tex: Texture, rect: Rect, color: RGBA=RGBA(255,255,255,255), flipX=False, flipY=False):
        if window.type == SurfaceType.WINDOW:
            lib.draw_texture_win(window._id, tex._id, rect.x, rect.y, rect.w, rect.h, color.r / 255.0, color.g / 255.0, color.b / 255.0, color.a / 255.0, flipX, flipY)
        elif window.type == SurfaceType.TEXTURE:
            lib.draw_texture_tex(window._id, tex._id, rect.x, rect.y, rect.w, rect.h, color.r / 255.0, color.g / 255.0, color.b / 255.0, color.a / 255.0, flipX, flipY)

    @staticmethod
    def text(window: Surface, font: Font, text: str, x: float, y: float, size: float, color: RGBA = RGBA(255,255,255,255)):
        if window.type == SurfaceType.WINDOW:
            lib.draw_text_win(window._id, font._id, text.encode("utf-8"), x, y, size / 1500, color.r / 255.0, color.g / 255.0, color.b / 255.0, color.a / 255.0)
        elif window.type == SurfaceType.TEXTURE:
            lib.draw_text_tex(window._id, font._id, text.encode("utf-8"), x, y, size / 1500, color.r / 255.0, color.g / 255.0, color.b / 255.0, color.a / 255.0)
