diff --git a/includes/script.js b/includes/script.js index 7669558..ffc7c54 100644 --- a/includes/script.js +++ b/includes/script.js @@ -203,9 +203,9 @@ $(document).ready(function() { for (var i = 0; i < rawData.length; i += 4) { // this brightness adjustment is pretty crude but whatever var pixel = { - red: Math.min(rawData[i ] + brightnessAdjustment, 255), - green: Math.min(rawData[i + 1] + brightnessAdjustment, 255), - blue: Math.min(rawData[i + 2] + brightnessAdjustment, 255), + red: _.clamp(rawData[i ] + brightnessAdjustment, 0, 255), + green: _.clamp(rawData[i + 1] + brightnessAdjustment, 0, 255), + blue: _.clamp(rawData[i + 2] + brightnessAdjustment, 0, 255), }; var targetColour = getClosestColour(pixel, palette);