mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Replace css color rgb(...) by #...
* it's faster to generate the color code in using a table for components * it's very likely a way faster to parse (when setting the color in the canvas)
This commit is contained in:
parent
bf870bd2ac
commit
9d11b51a3e
6 changed files with 15 additions and 18 deletions
|
@ -618,16 +618,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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue