marklovers / kaplay

🦖 A JavaScript game library
https://kaplayjs.com
MIT License
230 stars 14 forks source link

feat: Color.mult() takes a "blendFactor" parameter #188

Closed amyspark-ng closed 1 hour ago

amyspark-ng commented 5 days ago

So you can choose how "blended" 2 colors are when adding them to each other

mflerackers commented 5 days ago

Isn't that lerp? c1 a + c2 (a-1) or c1 + (c2-c1) * a

amyspark-ng commented 4 days ago

oh wait, you can pass 2 colors in lerp like this: obj.color = lerp(RED, BLUE, 0.5) 0 being red, 0.5 being the perfect mix and 1 being blue

i do still think it would be a nice feature wouldn't it? not everyone would be able to come up with a solution like this

mflerackers commented 4 days ago

But mult multiplies colors, it doesn't add/blend them. It is basically to reduce or mask certain color channels.

amyspark-ng commented 4 days ago

Ohhh i think i see what you mean, i just learned that there's a lerp function in the color type, now i feel silly

amyspark-ng commented 1 hour ago

BLUE.lerp(RED, 0.5) will return purple, problem fixed