Merge pull request #12555 from calixteman/color

Replace css color rgb(...) by #...
This commit is contained in:
Tim van der Meij 2020-11-02 23:55:39 +01:00 committed by GitHub
commit 3e52098e29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 18 deletions

View file

@ -622,16 +622,13 @@ const IsEvalSupportedCached = {
},
};
const rgbBuf = ["rgb(", 0, ",", 0, ",", 0, ")"];
const hexNumbers = [...Array(256).keys()].map(n =>
n.toString(16).padStart(2, "0")
);
class Util {
// makeCssRgb() can be called thousands of times. Using ´rgbBuf` avoids
// creating many intermediate strings.
static makeCssRgb(r, g, b) {
rgbBuf[1] = r;
rgbBuf[3] = g;
rgbBuf[5] = b;
return rgbBuf.join("");
static makeHexColor(r, g, b) {
return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
}
// Concatenates two transformation matrices together and returns the result.