Last active
August 29, 2015 14:07
-
-
Save RavensKrag/f64eae75de5e4eb68378 to your computer and use it in GitHub Desktop.
Better interface to get Chipmunk verts (still kinda messy)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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