# 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 trail

cdef class Trail:
    cdef SGTrail* handle
    
    def __init__(self, maxpoints):
        assert self.handle is NULL
        
        self.handle = sgTrailCreate(maxpoints)
        if self.handle is NULL:
            raise MemoryError()
    
    def __dealloc__(self):
        if self.handle is not NULL:
            self.destroy()
    
    cpdef destroy(self):
        assert self.handle is not NULL
        
        sgTrailDestroy(self.handle)
        self.handle = NULL
    
    def addPoint(self, x, y):
        assert self.handle is not NULL
        
        sgTrailAddPoint2f(self.handle, x, y)
    def addBreak(self):
        assert self.handle is not NULL
        
        sgTrailAddBreak(self.handle)
    
    def draw(self):
        assert self.handle is not NULL
        
        sgTrailDraw(self.handle)

