Skip to content

Commit aa77bcd

Browse files
authored
Merge pull request #1891 from mlarghydracept/hsb-colors-and-map-ing-#1826
Constrain HSB values after parsing for pattern #1826
2 parents 179cb40 + 2d03f10 commit aa77bcd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/color/p5.Color.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ p5.Color._parseInputs = function() {
537537
return parseInt(color, 10) / 100;
538538
});
539539
}
540+
results = results.map(function(value) {
541+
return Math.max(Math.min(value, 1), 0);
542+
});
540543
if (results.length) {
541544
return color_conversion._hslaToRGBA(results);
542545
}
@@ -563,6 +566,10 @@ p5.Color._parseInputs = function() {
563566
return parseInt(color, 10) / 100;
564567
});
565568
}
569+
results = results.map(function(value) {
570+
return Math.max(Math.min(value, 1), 0);
571+
});
572+
566573
if (results.length) {
567574
return color_conversion._hsbaToRGBA(results);
568575
}

0 commit comments

Comments
 (0)