Skip to content

Commit

Permalink
Altering to be Math.floor to pass test case but should be Mat.round a…
Browse files Browse the repository at this point in the history
…s far as I can see implementation wise in browsers
  • Loading branch information
themojache committed Apr 14, 2024
1 parent 940fed0 commit ac35047
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions lib/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,23 +298,21 @@ exports.parseColor = function parseColor(val) {
res = colorRegEx2.exec(val);
if (res) {
parts = res[1].split(rgbdelimiters);
[red, green, blue] = parts
.slice(0, 3)
.map((code) =>
code.toLowerCase() == 'none'
? 0
: Math.min(
255,
Math.max(
0,
percentRegEx.test(code)
? Math.round((parseFloat(code.slice(0, -1)) * 255) / 100)
: integerRegEx.test(code)
? parseInt(code, 10)
: undefined
)
[red, green, blue] = parts.slice(0, 3).map((code) =>
code.toLowerCase() == 'none'
? 0
: Math.min(
255,
Math.max(
0,
percentRegEx.test(code)
? Math.floor((parseFloat(code.slice(0, -1)) * 255) / 100) //Math.round
: integerRegEx.test(code)
? parseInt(code, 10)
: undefined
)
);
)
);
var base = [red, green, blue];
if (parts.length == 4) {
alpha =
Expand Down

0 comments on commit ac35047

Please sign in to comment.