Hello,
Anyone could write this code in a few minutes (like I did), but I thought I might as well share it for the new coders. Here it is:
function setup()
parameter.watch("1/DeltaTime")
m = getMesh(vec2(WIDTH,HEIGHT),
color(255, 0, 0, 255),
color(0, 52, 255, 255)
)
end
function draw()
background(0, 0, 0, 255)
m.setSize(
vec2(
math.random()*WIDTH,
math.random()*HEIGHT
)
)
m.setGradient(
color(math.random()*255,math.random()*255,math.random()*255),
color(math.random()*255,math.random()*255,math.random()*255)
)
pushMatrix()
translate(WIDTH/2,HEIGHT/2)
m:draw()
popMatrix()
end
function getMesh(size,color1,color2)
local m = mesh()
m.setSize = function(size)
m.vertices = {
vec2(-size.x/2,-size.y/2),
vec2(-size.x/2,size.y/2),
vec2(size.x/2,-size.y/2),
vec2(size.x/2,size.y/2),
vec2(-size.x/2,size.y/2),
vec2(size.x/2,-size.y/2)
}
end
m.setGradient = function(color1,color2)
m.colors = {
color2,
color1,
color2,
color1,
color1,
color2
}
end
m.setSize(size)
m.setGradient(color1,color2)
return m
end
I might add angles and multiple stops at some point, but I don’t have a need for that, so I’ll stick with 2 colors.
Thanks!