Hello guys, i made some kind of gradient/dynamic background.
But then it goes above the screen, it slows down each row, what can i do to optimize that ?
Here is two variants of code
First
--# Main
-- Gradient
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
colors = {}
for x = 1,10 do
colors[x] = {}
for y = 1,8 do
-- colors[x][y] = color(255,x*25,0)
colors[x][y] = vec3(255,0,0)
end
end
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
rectMode(CENTER)
local time = 0.5
background(40, 40, 50)
for k,v in pairs(colors) do
for a,b in pairs(v) do
pushStyle()
fill(b.x,b.y,0)
b.x = b.x + DeltaTime
b.y = b.y + time
if b.y > 255 or b.y < 0 then
b.y = 0
time = -time
end
rect(-50+k*100,-50+a*100,150,150)
popStyle()
end
end
-- This sets the line thickness
-- Do your drawing here
end
Second
--# Main
-- Gradient
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
colors = {}
for x = 1,10 do
colors[x] = vec3(255,0,0)
end
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
rectMode(CENTER)
local time = 0.5
background(40, 40, 50)
for k,b in pairs(colors) do
for a = 1,10 do
pushStyle()
fill(b.x,b.y,0)
b.x = b.x + DeltaTime
b.y = b.y + time
if b.y > 255 then
b.y = 0
time = -time
end
rect(-50+k*100,-50+a*100,150,150)
popStyle()
end
end
-- This sets the line thickness
-- Do your drawing here
end