Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Better interface to get Chipmunk verts (still kinda messy)
module CP
module Shape
class Poly
# return an array of all vertices
def verts
out = Array.new(self.num_verts)
self.num_verts.times do |i|
out[i] = self.vert(i)
end
return out
end
def area
CP.area_for_poly self.verts
end
include Enumerable
def each
self.num_verts.times do |i|
yield self.vert(i)
end
end
alias :each_vert :each
alias :each_vert_with_index :each_with_index
alias :each_vert_with_object :each_with_object
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.