I’m not even sure how to word it. I feel like I’m fighting a hydra. Chop one head off, two more appear. I’ve been inching my way to making my new function work as intended after hours of changing and tweaking stuff.
Here’s my biggest problem child:
local function paletteLightCalc()
local paletteLight = {}
local copyColorAmount = MAC
local secondRound = 0
local black = Color{ r=0, g=0, b=0, a=255 }
local white = Color{ r=255, g=255, b=255, a=255 }
-- If it has a center, remove and mark it
if copyColorAmount %2 == 1 then
copyColorAmount = copyColorAmount -1
hasCenter = true
end
-- Halve the number and prepare the second round
copyColorAmount = copyColorAmount/2
secondRound = copyColorAmount
-- Let's get the actual table now
-- Starting with black to normal
for i = 1, copyColorAmount do
local tempColor = CM
print(tempColor.lightness)
tempColor.lightness = inQuad(tempColor.lightness, black.lightness, black.lightness-tempColor.lightness, CT[i])
print(tempColor.lightness)
table.insert(paletteLight, Color(tempColor))
end
-- If it has a center, just add the main color in the middle
if hasCenter == true then
table.insert(paletteLight, CM)
secondRound = secondRound + 1
end
-- Lastly, normal to white
for y = 1, copyColorAmount do
local tempColor = CM
tempColor.lightness = inQuad(tempColor.lightness, white.lightness, white.lightness - tempColor.lightness, CT[y+secondRound])
table.insert(paletteLight, tempColor)
end
-- -- DEBUG
-- for k,v in pairs(paletteLight) do
-- print(v)
-- end
-- -- DEBUG END
return paletteLight
end
Full script here:
The for loop doesn’t reset the tempColor.
In the first line of my first for loop, I’m setting the tempColor to CM (Color Main/Main Color app.fgColor on startup)
But from all I can tell, it doesn’t get reset. In fact, after it runs, the main color gets somehow corrupted, even though I’m not doing anything to it directly, only to a copy of it.
It progressively gets worse aswell.
I first thought that I’ve somehow introduced a whole set bugs, but I’m now almost positive that all of them come from this.
I’m printing the lightness value of the tempColor before and after every calculation and get this:
Noteworthy, if I am reading CM instead, I’m getting the same numbers
Also, the easing function seems fairly broken. I’ve had to make tweaks to it so it would run in the first place (replacing math.pow with ^)
I’ve rewritten this topic partially a couple of times already because I’ve made changes, tested more, etc. My mental checklist of important things to mention here is a mess now, so forgive me if I forgot something crucial.
Thank you as always for your help!