mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 16:48:08 +02:00
Change how (most) fields are initialized in the CanvasExtraState
class
The majority of the class fields don't depend on any parameters, hence we can re-factor and shorten by this using modern JavaScript features.
This commit is contained in:
parent
624d8a418e
commit
010b6ad886
1 changed files with 56 additions and 32 deletions
|
@ -305,39 +305,63 @@ function drawImageAtIntegerCoords(
|
|||
}
|
||||
|
||||
class CanvasExtraState {
|
||||
constructor(width, height) {
|
||||
// Are soft masks and alpha values shapes or opacities?
|
||||
this.alphaIsShape = false;
|
||||
this.fontSize = 0;
|
||||
this.fontSizeScale = 1;
|
||||
this.textMatrix = IDENTITY_MATRIX;
|
||||
this.textMatrixScale = 1;
|
||||
this.fontMatrix = FONT_IDENTITY_MATRIX;
|
||||
this.leading = 0;
|
||||
// Current point (in user coordinates)
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
// Start of text line (in text coordinates)
|
||||
this.lineX = 0;
|
||||
this.lineY = 0;
|
||||
// Character and word spacing
|
||||
this.charSpacing = 0;
|
||||
this.wordSpacing = 0;
|
||||
this.textHScale = 1;
|
||||
this.textRenderingMode = TextRenderingMode.FILL;
|
||||
this.textRise = 0;
|
||||
// Default fore and background colors
|
||||
this.fillColor = "#000000";
|
||||
this.strokeColor = "#000000";
|
||||
this.patternFill = false;
|
||||
this.patternStroke = false;
|
||||
// Note: fill alpha applies to all non-stroking operations
|
||||
this.fillAlpha = 1;
|
||||
this.strokeAlpha = 1;
|
||||
this.lineWidth = 1;
|
||||
this.activeSMask = null;
|
||||
this.transferMaps = "none";
|
||||
// Are soft masks and alpha values shapes or opacities?
|
||||
alphaIsShape = false;
|
||||
|
||||
fontSize = 0;
|
||||
|
||||
fontSizeScale = 1;
|
||||
|
||||
textMatrix = IDENTITY_MATRIX;
|
||||
|
||||
textMatrixScale = 1;
|
||||
|
||||
fontMatrix = FONT_IDENTITY_MATRIX;
|
||||
|
||||
leading = 0;
|
||||
|
||||
// Current point (in user coordinates)
|
||||
x = 0;
|
||||
|
||||
y = 0;
|
||||
|
||||
// Start of text line (in text coordinates)
|
||||
lineX = 0;
|
||||
|
||||
lineY = 0;
|
||||
|
||||
// Character and word spacing
|
||||
charSpacing = 0;
|
||||
|
||||
wordSpacing = 0;
|
||||
|
||||
textHScale = 1;
|
||||
|
||||
textRenderingMode = TextRenderingMode.FILL;
|
||||
|
||||
textRise = 0;
|
||||
|
||||
// Default fore and background colors
|
||||
fillColor = "#000000";
|
||||
|
||||
strokeColor = "#000000";
|
||||
|
||||
patternFill = false;
|
||||
|
||||
patternStroke = false;
|
||||
|
||||
// Note: fill alpha applies to all non-stroking operations
|
||||
fillAlpha = 1;
|
||||
|
||||
strokeAlpha = 1;
|
||||
|
||||
lineWidth = 1;
|
||||
|
||||
activeSMask = null;
|
||||
|
||||
transferMaps = "none";
|
||||
|
||||
constructor(width, height) {
|
||||
this.clipBox = new Float32Array([0, 0, width, height]);
|
||||
this.minMax = MIN_MAX_INIT.slice();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue