# Copyright (c) 2007 SIEGE Development Team
# All rights reserved.
#
# This file is part of libSIEGE.
#
# This software is copyrighted work licensed under the terms of the
# 2-clause BSD license. Please consult the file "license.txt" for
# details.
#
# If you did not recieve the file with this program, please email
# Tim Chas <darkuranium@gmail.com>.

from siege.common cimport *
cimport draw
from texture cimport Texture

def begin(SGenum type, Texture texture):
    if texture is None:
        sgDrawBegin(type)
    else:
        sgDrawBeginT(type, texture.handle)

def end():
    sgDrawEnd()

def colorf(r, g = None, b = None, a = None):
    if a is None:
        if b is None:
            if g is None:
                sgDrawColor1f(r)
            else:
                sgDrawColor2f(r, g)
        else:
            sgDrawColor3f(r, g, b)
    else:
        sgDrawColor4f(r, g, b, a)

def colorub(r, g = None, b = None, a = None):
    if a is None:
        if b is None:
            if g is None:
                sgDrawColor1ub(r)
            else:
                sgDrawColor2ub(r, g)
        else:
            sgDrawColor3ub(r, g, b)
    else:
        sgDrawColor4ub(r, g, b, a)

def texCoord(s, t):
    sgDrawTexCoord2f(s, t)

def vertex(x, y, z = None):
    if z is None:
        sgDrawVertex2f(x, y)
    else:
        sgDrawVertex3f(x, y, z)

def clearf(r = None, g = None, b = None, a = None):
    if a is None:
        if b is None:
            if g is None:
                if r is None:
                    sgDrawClear()
                else:
                    sgDrawClear1f(r)
            else:
                sgDrawClear2f(r, g)
        else:
            sgDrawClear3f(r, g, b)
    else:
        sgDrawClear4f(r, g, b, a)

def clearub(r = None, g = None, b = None, a = None):
    if a is None:
        if b is None:
            if g is None:
                if r is None:
                    sgDrawClear()
                else:
                    sgDrawClear1ub(r)
            else:
                sgDrawClear2ub(r, g)
        else:
            sgDrawClear3ub(r, g, b)
    else:
        sgDrawClear4ub(r, g, b, a)

def clear():
    sgDrawClear()

def setBlendFunc(SGenum src, SGenum dst):
    sgDrawSetBlendFunc(src, dst)

def setBlendEquation(SGenum equation):
    sgDrawSetBlendEquation(equation)

def point(x, y):
    sgDrawPoint(x, y)
def pointSetSize(size):
    sgDrawPointSetSize(size)

def line(x1, y1, x2, y2):
    sgDrawLine(x1, y1, x2, y2)
def lineSetWidth(width):
    sgDrawLineSetWidth(width)

def triangle(x1, y1, x2, y2, x3, y3, fill = True):
    sgDrawTriangle(x1, y1, x2, y2, x3, y3, fill)
def quad(x1, y1, x2, y2, x3, y3, x4, y4, fill = True):
    sgDrawQuad(x1, y1, x2, y2, x3, y3, x4, y4, fill)
def rectangle(x1, y1, x2, y2, fill = True):
    sgDrawRectangle(x1, y1, x2, y2, fill)
def ellipse2R(x, y, rx, ry, fill = True):
    sgDrawEllipse2R(x, y, rx, ry, fill)
def circle(x, y, radius, fill = True):
    sgDrawCircle(x, y, radius, fill)

def earcRads(x, y, rx, ry, a1, a2, SGbool ccw = 1, fill = True):
    sgDrawEArcRads(x, y, rx, ry, a1, a2, ccw, fill)
def earcDegs(x, y, rx, ry, a1, a2, SGbool ccw = 1, fill = True):
    sgDrawEArcDegs(x, y, rx, ry, a1, a2, ccw, fill)

def arcRads(x, y, r, a1, a2, SGbool ccw = 1, fill = True):
    sgDrawArcRads(x, y, r, a1, a2, ccw, fill)
def arcDegs(x, y, r, a1, a2, SGbool ccw = 1, fill = True):
    sgDrawArcDegs(x, y, r, a1, a2, ccw, fill)
