From c79cca778f889b2b4956ae0078b966b4cdc36cdd Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Wed, 27 Dec 2017 17:03:27 +0000 Subject: [PATCH] clamp rgb values to 0-255 --- includes/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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);