fixed rgbToHex rounding

This commit is contained in:
Lily-129 2022-04-19 09:05:04 -04:00 committed by GitHub
parent 959164a73d
commit 56581d12fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -117,15 +117,15 @@ function _rgbToHex(color) {
};
//console.log("Concatenating");
return "#" + red + green + blue;
} else if(typeof(color) == "string") { //Expects string like "rgb(20,137,4)". Also doesn't round properly for some reason...
} else if(typeof(color) == "string") { //Expects string like "rgb(20,137,4)".
//console.log("Splitting string")
color = color.split(",");
//console.log("Getting R");
var red = parseInt(color[0].substring(4))
var red = parseFloat(color[0].substring(4))
//console.log("Getting G");
var green = parseInt(color[1])
var green = parseFloat(color[1])
//console.log("Getting B");
var blue = parseInt(color[2].slice(0,-1))
var blue = parseFloat(color[2].slice(0,-1))
//console.log("Rounding R");
red = Math.round(red);
//console.log("Rounding G");