puzzle/game/Color.js
2020-11-07 11:35:29 +01:00

22 lines
496 B
JavaScript

export function tint(c, f) {
return [
Math.max(0, Math.min(255, Math.round((255 - c[0]) * f))),
Math.max(0, Math.min(255, Math.round((255 - c[1]) * f))),
Math.max(0, Math.min(255, Math.round((255 - c[2]) * f))),
c[3]
]
}
export function shade(c, f) {
return [
Math.max(0, Math.min(255, Math.round(c[0] * f))),
Math.max(0, Math.min(255, Math.round(c[1] * f))),
Math.max(0, Math.min(255, Math.round(c[2] * f))),
c[3]
]
}
export default {
tint,
shade
}