clamp rgb values to 0-255
This commit is contained in:
parent
002863b88a
commit
c79cca778f
|
@ -203,9 +203,9 @@ $(document).ready(function() {
|
||||||
for (var i = 0; i < rawData.length; i += 4) {
|
for (var i = 0; i < rawData.length; i += 4) {
|
||||||
// this brightness adjustment is pretty crude but whatever
|
// this brightness adjustment is pretty crude but whatever
|
||||||
var pixel = {
|
var pixel = {
|
||||||
red: Math.min(rawData[i ] + brightnessAdjustment, 255),
|
red: _.clamp(rawData[i ] + brightnessAdjustment, 0, 255),
|
||||||
green: Math.min(rawData[i + 1] + brightnessAdjustment, 255),
|
green: _.clamp(rawData[i + 1] + brightnessAdjustment, 0, 255),
|
||||||
blue: Math.min(rawData[i + 2] + brightnessAdjustment, 255),
|
blue: _.clamp(rawData[i + 2] + brightnessAdjustment, 0, 255),
|
||||||
};
|
};
|
||||||
|
|
||||||
var targetColour = getClosestColour(pixel, palette);
|
var targetColour = getClosestColour(pixel, palette);
|
||||||
|
|
Loading…
Reference in New Issue