Hi,

before doing a real project, im trying some stuff.

While playing with a touch-gesture to zoom objects, i experienced a noteable drop in performance as the objects get bigger.

Im just drawing a Square and an Ellipse… how can that be sooo expensive?

Any Ideas what I’m doing wrong?

Thanks in advance,

lupo

Here’s the full Code:

```
--# Main
function setup()
displayMode(FULLSCREEN)
size = 200
touches = {}
touchcount = 0
x = WIDTH / 2
y = HEIGHT / 2
objects = {Rect(),Ellipse()}
end
function draw()
background(0, 0, 0, 255)
for k,obj in ipairs(objects) do
obj:draw()
end
end
function updateObjects()
for i,obj in ipairs(objects) do
obj.x = x
obj.y = y
obj.size = size
end
end
function touched(touch)
if touch.state == ENDED then
touches[touch.id] = nil
touchcount = touchcount - 1
else
touches[touch.id] = touch
if touch.state == BEGAN then
touchcount = touchcount + 1
end
end
if touchcount == 1 then
if not (touch.state == ENDED) then
x = touch.x
y = touch.y
end
elseif touchcount == 2 then
for k,othertouch in pairs(touches) do
if not (touch.id == othertouch.id) then
x = math.min(touch.x, othertouch.x) + math.abs( touch.x - othertouch.x ) / 2
y = math.min(touch.y, othertouch.y) + math.abs( touch.y - othertouch.y ) / 2
size = math.sqrt( math.pow((touch.x - othertouch.x),2) + math.pow((touch.y - othertouch.y),2) )
end
end
end
updateObjects()
end
--# Ellipse
Ellipse = class()
function Ellipse:init()
self.x = WIDTH / 2
self.y = HEIGHT / 2
self.size = 200
end
function Ellipse:draw()
pushMatrix()
strokeWidth(5)
stroke(190, 151, 59, 59)
ellipse(self.x, self.y, self.size)
fill(203, 64, 64, 255)
popMatrix()
end
--# Rect
Rect = class()
function Rect:init()
self.x = WIDTH / 2
self.y = HEIGHT / 2
self.size = 200
end
function Rect:draw()
strokeWidth(5)
stroke(155, 48, 48, 70)
rect(self.x - self.size / 2, self.y - self.size / 2, self.size, self.size)
fill(72, 63, 203, 255)
end
```