Add moveTo

This commit is contained in:
Matthias Richter 2011-01-24 20:37:17 +01:00
parent 4a24422e54
commit 896f58110e

View File

@ -57,6 +57,11 @@ end
local Shape = Class{name = 'Shape', function(self, t) local Shape = Class{name = 'Shape', function(self, t)
self._type = t self._type = t
end} end}
function Shape:moveTo(x,y)
local current = vector( self:center() )
local to = vector.isvector(x) and x or vector(x,y)
self:move( to-current )
end
-- supported shapes -- supported shapes
Shape.POLYGON = setmetatable({}, {__tostring = function() return 'POLYGON' end}) Shape.POLYGON = setmetatable({}, {__tostring = function() return 'POLYGON' end})