How can I make the rgb a rainbow like those fancy chairs?
I tried using variables but that didnt work, the code is
init = function()
r=0
b=0
g=0
end
draw=function()
screen.clear()
screen.setAlpha(1)
r=r+1
g=g+2
b=b+3
screen.fillRect(0,0,200,80, "rgb(r, g, b)")
if r == 255 then
r=0
end
if g == 254 then
g=0
end
if b==255 then
b=0
end
end
and the colours of the box don't change, it is very annoying >:(
Okay, it doesn't work because you don't have the function that mixes colors. Try this code.
init = function()
time = 2
r = random.next() * 255
g = random.next() * 255
b = random.next() * 255
width = 30
height = 30
end
update = function()
time = time - 1/60
if time <= 0 then
r = random.next() * 255
g = random.next() * 255
b = random.next() * 255
time = 2
end
width = 30 + cos(system.time() / 100) * 10
height = 30 + sin(system.time() / 100) * 10
end
draw = function()
screen.clear()
screen.fillRect(0, 0, width, height, "rgb(" + r + "," + g + "," + b + ")")
screen.drawText("multicolor square", 0, -50, 15, "white")
end