 #= require math
 
 
+
+#
+# This class represents an arbitrary convex polygon
+#
 class wolf.Polygon extends wolf.Element
     
     @key : 'wolf.Polygon'

        delta = point.subtract(@getPosition())
        return @setVertices((v.add(delta) for v in @vertices), silent)

    render : (context) ->
        [first, rest...] = @vertices
        context.beginPath()

        @trigger('moved', @) if changed and not silent
        this

    # Return the point at the geometrical center of the element.
    getCenter : ()  ->
        c = @vertices.reduce((p, v) ->
            return p.add(v)
        , new wolf.Point(0, 0))
        c.x = c.x / @vertices.length
        c.y = c.y / @vertices.length
        return c

    # Rotate the element counter-clockwise by the given number of degrees.
    rotate : (degrees, silent=false) ->
        return this if not degrees
        c = @getCenter()
