Anatoly
October 10, 2016, 12:14pm
1
This code:
function CreateGraphic:formula()
--[[
Function is called like this in 'draw':
local img = self:formula()
sprite(img, (WIDTH+225)/2, HEIGHT/2+50, 700, 450)
]]
img = image(450, 300)
setContext(img)
fill(127, 127, 127, 255)
rect(0, 0, 450, 300)
setContext()
return img
end
It’s definitely this function, because when commenting it, it won’t crash Codea. :neutral:
Ignatz
October 10, 2016, 12:21pm
2
The function looks like it calls itself, so it goes round and round until it crashes
Anatoly
October 10, 2016, 12:23pm
3
What do you mean by “calls itself”?
I am not calling the function anywhere else…
Anatoly
October 10, 2016, 12:28pm
4
Instead of making another function, I have put the code part in ‘draw’, and it was still crashing:
-- Show Diagramm
img = image(450, 300)
setContext(img)
fill(127, 127, 127, 255)
rect(0, 0, 450, 300)
setContext()
sprite(img, (WIDTH+225)/2, HEIGHT/2+50, 700, 450)
Still crashes
Ignatz
October 10, 2016, 12:59pm
5
Why are you using setContext every time you draw?
Okey, Fixed, creating new images 60 times a miliseconds is crashing Codea.
Just made it being elements…
Bri_G
October 10, 2016, 5:48pm
7
Hi,
Try putting your image generation in setup then just sprite the image in draw:
displayMode(OVERLAY)
function setup()
img = image(450, 300)
setContext(img)
fill(127, 127, 127, 255)
rect(0, 0, 449, 299)
setContext()
end
function draw()
background(50,50,50,255)
sprite(img, WIDTH/2, HEIGHT/2)
end
Make sure the size of your img is the same size as the rectangle.
Bri_G
But it should be updated automatically…