in my puzzle game i have colored rects i want to blend / mix. for instance mixing yellow and blue should turn those rects into Green rects. i also want this to happen over time as well, so the actual color change should take 1 second before its complete. im looking for ideas on how i can do this. my own thoughts seem super complex
here is parts of the code
brush class
Brush = class()
function Brush:init(s, p, c, index)
self.pos = p
self.size = s
self.col = c
self.ind = index
self.score = false
end
function Brush:draw()
pushStyle()
fill(self.col)
rectMode(CENTER)
rect(self.pos.x, self.pos.y, self.size, self.size)
popStyle()
end
main class setup were the colors i use a defined and were i create the brush
-- Main
function setup()
-- colors
colors = {
color(255, 0, 0), -- red
color(255, 163, 0), --orange
color(255, 255, 0), --yellow
color(0, 255, 0), -- green
color(0, 0, 255), --blue
color(192, 0, 255), --purple
color(180, 180, 180) --gray
}
-- create a palette to place brushes on
palette = {}
paletteWidth = math.min(WIDTH,HEIGHT) -- <<<<
paletteHeiht = paletteWidth -- <<<<
brushWidth = paletteWidth/6
brushHeight = paletteWidth/6
startX = brushWidth/2
startY = brushHeight/2+brushHeight
counter = 1
for i=1, 12 do
palette[i] = {}
for j=1, 6 do
local brushColor = randomColor()
palette[i][j] = Brush(paletteWidth/6, vec2(startX,startY), brushColor, counter)
startX = startX + brushWidth
counter = counter + 1
end
startX = brushWidth/2
startY = startY + brushHeight
end
end