|
|
@ -20,56 +20,6 @@ var TextRenderingMode = { |
|
|
|
// Minimal font size that would be used during canvas fillText operations.
|
|
|
|
// Minimal font size that would be used during canvas fillText operations.
|
|
|
|
var MIN_FONT_SIZE = 1; |
|
|
|
var MIN_FONT_SIZE = 1; |
|
|
|
|
|
|
|
|
|
|
|
var CanvasExtraState = (function CanvasExtraStateClosure() { |
|
|
|
|
|
|
|
function CanvasExtraState(old) { |
|
|
|
|
|
|
|
// Are soft masks and alpha values shapes or opacities?
|
|
|
|
|
|
|
|
this.alphaIsShape = false; |
|
|
|
|
|
|
|
this.fontSize = 0; |
|
|
|
|
|
|
|
this.fontSizeScale = 1; |
|
|
|
|
|
|
|
this.textMatrix = IDENTITY_MATRIX; |
|
|
|
|
|
|
|
this.fontMatrix = 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; |
|
|
|
|
|
|
|
// Color spaces
|
|
|
|
|
|
|
|
this.fillColorSpace = new DeviceGrayCS(); |
|
|
|
|
|
|
|
this.fillColorSpaceObj = null; |
|
|
|
|
|
|
|
this.strokeColorSpace = new DeviceGrayCS(); |
|
|
|
|
|
|
|
this.strokeColorSpaceObj = null; |
|
|
|
|
|
|
|
this.fillColorObj = null; |
|
|
|
|
|
|
|
this.strokeColorObj = null; |
|
|
|
|
|
|
|
// Default fore and background colors
|
|
|
|
|
|
|
|
this.fillColor = '#000000'; |
|
|
|
|
|
|
|
this.strokeColor = '#000000'; |
|
|
|
|
|
|
|
// Note: fill alpha applies to all non-stroking operations
|
|
|
|
|
|
|
|
this.fillAlpha = 1; |
|
|
|
|
|
|
|
this.strokeAlpha = 1; |
|
|
|
|
|
|
|
this.lineWidth = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.old = old; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CanvasExtraState.prototype = { |
|
|
|
|
|
|
|
clone: function canvasextra_clone() { |
|
|
|
|
|
|
|
return Object.create(this); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
setCurrentPoint: function canvasextra_setCurrentPoint(x, y) { |
|
|
|
|
|
|
|
this.x = x; |
|
|
|
|
|
|
|
this.y = y; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return CanvasExtraState; |
|
|
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createScratchCanvas(width, height) { |
|
|
|
function createScratchCanvas(width, height) { |
|
|
|
var canvas = document.createElement('canvas'); |
|
|
|
var canvas = document.createElement('canvas'); |
|
|
|
canvas.width = width; |
|
|
|
canvas.width = width; |
|
|
@ -187,6 +137,56 @@ function addContextCurrentTransform(ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var CanvasExtraState = (function CanvasExtraStateClosure() { |
|
|
|
|
|
|
|
function CanvasExtraState(old) { |
|
|
|
|
|
|
|
// Are soft masks and alpha values shapes or opacities?
|
|
|
|
|
|
|
|
this.alphaIsShape = false; |
|
|
|
|
|
|
|
this.fontSize = 0; |
|
|
|
|
|
|
|
this.fontSizeScale = 1; |
|
|
|
|
|
|
|
this.textMatrix = IDENTITY_MATRIX; |
|
|
|
|
|
|
|
this.fontMatrix = 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; |
|
|
|
|
|
|
|
// Color spaces
|
|
|
|
|
|
|
|
this.fillColorSpace = new DeviceGrayCS(); |
|
|
|
|
|
|
|
this.fillColorSpaceObj = null; |
|
|
|
|
|
|
|
this.strokeColorSpace = new DeviceGrayCS(); |
|
|
|
|
|
|
|
this.strokeColorSpaceObj = null; |
|
|
|
|
|
|
|
this.fillColorObj = null; |
|
|
|
|
|
|
|
this.strokeColorObj = null; |
|
|
|
|
|
|
|
// Default fore and background colors
|
|
|
|
|
|
|
|
this.fillColor = '#000000'; |
|
|
|
|
|
|
|
this.strokeColor = '#000000'; |
|
|
|
|
|
|
|
// Note: fill alpha applies to all non-stroking operations
|
|
|
|
|
|
|
|
this.fillAlpha = 1; |
|
|
|
|
|
|
|
this.strokeAlpha = 1; |
|
|
|
|
|
|
|
this.lineWidth = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.old = old; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CanvasExtraState.prototype = { |
|
|
|
|
|
|
|
clone: function CanvasExtraState_clone() { |
|
|
|
|
|
|
|
return Object.create(this); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) { |
|
|
|
|
|
|
|
this.x = x; |
|
|
|
|
|
|
|
this.y = y; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return CanvasExtraState; |
|
|
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
// Defines the time the executeOperatorList is going to be executing
|
|
|
|
// Defines the time the executeOperatorList is going to be executing
|
|
|
|
// before it stops and shedules a continue of execution.
|
|
|
|
// before it stops and shedules a continue of execution.
|
|
|
@ -241,7 +241,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
'shadingFill': true |
|
|
|
'shadingFill': true |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
beginDrawing: function canvasGraphicsBeginDrawing(mediaBox) { |
|
|
|
beginDrawing: function CanvasGraphics_beginDrawing(mediaBox) { |
|
|
|
var cw = this.ctx.canvas.width, ch = this.ctx.canvas.height; |
|
|
|
var cw = this.ctx.canvas.width, ch = this.ctx.canvas.height; |
|
|
|
this.ctx.save(); |
|
|
|
this.ctx.save(); |
|
|
|
switch (mediaBox.rotate) { |
|
|
|
switch (mediaBox.rotate) { |
|
|
@ -267,7 +267,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.textLayer.beginLayout(); |
|
|
|
this.textLayer.beginLayout(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
executeOperatorList: function canvasGraphicsExecuteOperatorList( |
|
|
|
executeOperatorList: function CanvasGraphics_executeOperatorList( |
|
|
|
operatorList, |
|
|
|
operatorList, |
|
|
|
executionStartIdx, continueCallback, |
|
|
|
executionStartIdx, continueCallback, |
|
|
|
stepper) { |
|
|
|
stepper) { |
|
|
@ -332,7 +332,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
endDrawing: function canvasGraphicsEndDrawing() { |
|
|
|
endDrawing: function CanvasGraphics_endDrawing() { |
|
|
|
this.ctx.restore(); |
|
|
|
this.ctx.restore(); |
|
|
|
|
|
|
|
|
|
|
|
if (this.textLayer) |
|
|
|
if (this.textLayer) |
|
|
@ -340,32 +340,32 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Graphics state
|
|
|
|
// Graphics state
|
|
|
|
setLineWidth: function canvasGraphicsSetLineWidth(width) { |
|
|
|
setLineWidth: function CanvasGraphics_setLineWidth(width) { |
|
|
|
this.current.lineWidth = width; |
|
|
|
this.current.lineWidth = width; |
|
|
|
this.ctx.lineWidth = width; |
|
|
|
this.ctx.lineWidth = width; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setLineCap: function canvasGraphicsSetLineCap(style) { |
|
|
|
setLineCap: function CanvasGraphics_setLineCap(style) { |
|
|
|
this.ctx.lineCap = LINE_CAP_STYLES[style]; |
|
|
|
this.ctx.lineCap = LINE_CAP_STYLES[style]; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setLineJoin: function canvasGraphicsSetLineJoin(style) { |
|
|
|
setLineJoin: function CanvasGraphics_setLineJoin(style) { |
|
|
|
this.ctx.lineJoin = LINE_JOIN_STYLES[style]; |
|
|
|
this.ctx.lineJoin = LINE_JOIN_STYLES[style]; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setMiterLimit: function canvasGraphicsSetMiterLimit(limit) { |
|
|
|
setMiterLimit: function CanvasGraphics_setMiterLimit(limit) { |
|
|
|
this.ctx.miterLimit = limit; |
|
|
|
this.ctx.miterLimit = limit; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setDash: function canvasGraphicsSetDash(dashArray, dashPhase) { |
|
|
|
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) { |
|
|
|
this.ctx.mozDash = dashArray; |
|
|
|
this.ctx.mozDash = dashArray; |
|
|
|
this.ctx.mozDashOffset = dashPhase; |
|
|
|
this.ctx.mozDashOffset = dashPhase; |
|
|
|
this.ctx.webkitLineDash = dashArray; |
|
|
|
this.ctx.webkitLineDash = dashArray; |
|
|
|
this.ctx.webkitLineDashOffset = dashPhase; |
|
|
|
this.ctx.webkitLineDashOffset = dashPhase; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setRenderingIntent: function canvasGraphicsSetRenderingIntent(intent) { |
|
|
|
setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) { |
|
|
|
TODO('set rendering intent: ' + intent); |
|
|
|
TODO('set rendering intent: ' + intent); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setFlatness: function canvasGraphicsSetFlatness(flatness) { |
|
|
|
setFlatness: function CanvasGraphics_setFlatness(flatness) { |
|
|
|
TODO('set flatness: ' + flatness); |
|
|
|
TODO('set flatness: ' + flatness); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setGState: function canvasGraphicsSetGState(states) { |
|
|
|
setGState: function CanvasGraphics_setGState(states) { |
|
|
|
for (var i = 0, ii = states.length; i < ii; i++) { |
|
|
|
for (var i = 0, ii = states.length; i < ii; i++) { |
|
|
|
var state = states[i]; |
|
|
|
var state = states[i]; |
|
|
|
var key = state[0]; |
|
|
|
var key = state[0]; |
|
|
@ -406,52 +406,52 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
save: function canvasGraphicsSave() { |
|
|
|
save: function CanvasGraphics_save() { |
|
|
|
this.ctx.save(); |
|
|
|
this.ctx.save(); |
|
|
|
var old = this.current; |
|
|
|
var old = this.current; |
|
|
|
this.stateStack.push(old); |
|
|
|
this.stateStack.push(old); |
|
|
|
this.current = old.clone(); |
|
|
|
this.current = old.clone(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
restore: function canvasGraphicsRestore() { |
|
|
|
restore: function CanvasGraphics_restore() { |
|
|
|
var prev = this.stateStack.pop(); |
|
|
|
var prev = this.stateStack.pop(); |
|
|
|
if (prev) { |
|
|
|
if (prev) { |
|
|
|
this.current = prev; |
|
|
|
this.current = prev; |
|
|
|
this.ctx.restore(); |
|
|
|
this.ctx.restore(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
transform: function canvasGraphicsTransform(a, b, c, d, e, f) { |
|
|
|
transform: function CanvasGraphics_transform(a, b, c, d, e, f) { |
|
|
|
this.ctx.transform(a, b, c, d, e, f); |
|
|
|
this.ctx.transform(a, b, c, d, e, f); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Path
|
|
|
|
// Path
|
|
|
|
moveTo: function canvasGraphicsMoveTo(x, y) { |
|
|
|
moveTo: function CanvasGraphics_moveTo(x, y) { |
|
|
|
this.ctx.moveTo(x, y); |
|
|
|
this.ctx.moveTo(x, y); |
|
|
|
this.current.setCurrentPoint(x, y); |
|
|
|
this.current.setCurrentPoint(x, y); |
|
|
|
}, |
|
|
|
}, |
|
|
|
lineTo: function canvasGraphicsLineTo(x, y) { |
|
|
|
lineTo: function CanvasGraphics_lineTo(x, y) { |
|
|
|
this.ctx.lineTo(x, y); |
|
|
|
this.ctx.lineTo(x, y); |
|
|
|
this.current.setCurrentPoint(x, y); |
|
|
|
this.current.setCurrentPoint(x, y); |
|
|
|
}, |
|
|
|
}, |
|
|
|
curveTo: function canvasGraphicsCurveTo(x1, y1, x2, y2, x3, y3) { |
|
|
|
curveTo: function CanvasGraphics_curveTo(x1, y1, x2, y2, x3, y3) { |
|
|
|
this.ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3); |
|
|
|
this.ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3); |
|
|
|
this.current.setCurrentPoint(x3, y3); |
|
|
|
this.current.setCurrentPoint(x3, y3); |
|
|
|
}, |
|
|
|
}, |
|
|
|
curveTo2: function canvasGraphicsCurveTo2(x2, y2, x3, y3) { |
|
|
|
curveTo2: function CanvasGraphics_curveTo2(x2, y2, x3, y3) { |
|
|
|
var current = this.current; |
|
|
|
var current = this.current; |
|
|
|
this.ctx.bezierCurveTo(current.x, current.y, x2, y2, x3, y3); |
|
|
|
this.ctx.bezierCurveTo(current.x, current.y, x2, y2, x3, y3); |
|
|
|
current.setCurrentPoint(x3, y3); |
|
|
|
current.setCurrentPoint(x3, y3); |
|
|
|
}, |
|
|
|
}, |
|
|
|
curveTo3: function canvasGraphicsCurveTo3(x1, y1, x3, y3) { |
|
|
|
curveTo3: function CanvasGraphics_curveTo3(x1, y1, x3, y3) { |
|
|
|
this.curveTo(x1, y1, x3, y3, x3, y3); |
|
|
|
this.curveTo(x1, y1, x3, y3, x3, y3); |
|
|
|
this.current.setCurrentPoint(x3, y3); |
|
|
|
this.current.setCurrentPoint(x3, y3); |
|
|
|
}, |
|
|
|
}, |
|
|
|
closePath: function canvasGraphicsClosePath() { |
|
|
|
closePath: function CanvasGraphics_closePath() { |
|
|
|
this.ctx.closePath(); |
|
|
|
this.ctx.closePath(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
rectangle: function canvasGraphicsRectangle(x, y, width, height) { |
|
|
|
rectangle: function CanvasGraphics_rectangle(x, y, width, height) { |
|
|
|
this.ctx.rect(x, y, width, height); |
|
|
|
this.ctx.rect(x, y, width, height); |
|
|
|
}, |
|
|
|
}, |
|
|
|
stroke: function canvasGraphicsStroke(consumePath) { |
|
|
|
stroke: function CanvasGraphics_stroke(consumePath) { |
|
|
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; |
|
|
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; |
|
|
|
var ctx = this.ctx; |
|
|
|
var ctx = this.ctx; |
|
|
|
var strokeColor = this.current.strokeColor; |
|
|
|
var strokeColor = this.current.strokeColor; |
|
|
@ -476,11 +476,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
// Restore the global alpha to the fill alpha
|
|
|
|
// Restore the global alpha to the fill alpha
|
|
|
|
ctx.globalAlpha = this.current.fillAlpha; |
|
|
|
ctx.globalAlpha = this.current.fillAlpha; |
|
|
|
}, |
|
|
|
}, |
|
|
|
closeStroke: function canvasGraphicsCloseStroke() { |
|
|
|
closeStroke: function CanvasGraphics_closeStroke() { |
|
|
|
this.closePath(); |
|
|
|
this.closePath(); |
|
|
|
this.stroke(); |
|
|
|
this.stroke(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
fill: function canvasGraphicsFill(consumePath) { |
|
|
|
fill: function CanvasGraphics_fill(consumePath) { |
|
|
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; |
|
|
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; |
|
|
|
var ctx = this.ctx; |
|
|
|
var ctx = this.ctx; |
|
|
|
var fillColor = this.current.fillColor; |
|
|
|
var fillColor = this.current.fillColor; |
|
|
@ -497,65 +497,65 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
if (consumePath) |
|
|
|
if (consumePath) |
|
|
|
this.consumePath(); |
|
|
|
this.consumePath(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
eoFill: function canvasGraphicsEoFill() { |
|
|
|
eoFill: function CanvasGraphics_eoFill() { |
|
|
|
var savedFillRule = this.setEOFillRule(); |
|
|
|
var savedFillRule = this.setEOFillRule(); |
|
|
|
this.fill(); |
|
|
|
this.fill(); |
|
|
|
this.restoreFillRule(savedFillRule); |
|
|
|
this.restoreFillRule(savedFillRule); |
|
|
|
}, |
|
|
|
}, |
|
|
|
fillStroke: function canvasGraphicsFillStroke() { |
|
|
|
fillStroke: function CanvasGraphics_fillStroke() { |
|
|
|
this.fill(false); |
|
|
|
this.fill(false); |
|
|
|
this.stroke(false); |
|
|
|
this.stroke(false); |
|
|
|
|
|
|
|
|
|
|
|
this.consumePath(); |
|
|
|
this.consumePath(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
eoFillStroke: function canvasGraphicsEoFillStroke() { |
|
|
|
eoFillStroke: function CanvasGraphics_eoFillStroke() { |
|
|
|
var savedFillRule = this.setEOFillRule(); |
|
|
|
var savedFillRule = this.setEOFillRule(); |
|
|
|
this.fillStroke(); |
|
|
|
this.fillStroke(); |
|
|
|
this.restoreFillRule(savedFillRule); |
|
|
|
this.restoreFillRule(savedFillRule); |
|
|
|
}, |
|
|
|
}, |
|
|
|
closeFillStroke: function canvasGraphicsCloseFillStroke() { |
|
|
|
closeFillStroke: function CanvasGraphics_closeFillStroke() { |
|
|
|
this.closePath(); |
|
|
|
this.closePath(); |
|
|
|
this.fillStroke(); |
|
|
|
this.fillStroke(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
closeEOFillStroke: function canvasGraphicsCloseEOFillStroke() { |
|
|
|
closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() { |
|
|
|
var savedFillRule = this.setEOFillRule(); |
|
|
|
var savedFillRule = this.setEOFillRule(); |
|
|
|
this.closePath(); |
|
|
|
this.closePath(); |
|
|
|
this.fillStroke(); |
|
|
|
this.fillStroke(); |
|
|
|
this.restoreFillRule(savedFillRule); |
|
|
|
this.restoreFillRule(savedFillRule); |
|
|
|
}, |
|
|
|
}, |
|
|
|
endPath: function canvasGraphicsEndPath() { |
|
|
|
endPath: function CanvasGraphics_endPath() { |
|
|
|
this.consumePath(); |
|
|
|
this.consumePath(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Clipping
|
|
|
|
// Clipping
|
|
|
|
clip: function canvasGraphicsClip() { |
|
|
|
clip: function CanvasGraphics_clip() { |
|
|
|
this.pendingClip = NORMAL_CLIP; |
|
|
|
this.pendingClip = NORMAL_CLIP; |
|
|
|
}, |
|
|
|
}, |
|
|
|
eoClip: function canvasGraphicsEoClip() { |
|
|
|
eoClip: function CanvasGraphics_eoClip() { |
|
|
|
this.pendingClip = EO_CLIP; |
|
|
|
this.pendingClip = EO_CLIP; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Text
|
|
|
|
// Text
|
|
|
|
beginText: function canvasGraphicsBeginText() { |
|
|
|
beginText: function CanvasGraphics_beginText() { |
|
|
|
this.current.textMatrix = IDENTITY_MATRIX; |
|
|
|
this.current.textMatrix = IDENTITY_MATRIX; |
|
|
|
this.current.x = this.current.lineX = 0; |
|
|
|
this.current.x = this.current.lineX = 0; |
|
|
|
this.current.y = this.current.lineY = 0; |
|
|
|
this.current.y = this.current.lineY = 0; |
|
|
|
}, |
|
|
|
}, |
|
|
|
endText: function canvasGraphicsEndText() { |
|
|
|
endText: function CanvasGraphics_endText() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
setCharSpacing: function canvasGraphicsSetCharSpacing(spacing) { |
|
|
|
setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) { |
|
|
|
this.current.charSpacing = spacing; |
|
|
|
this.current.charSpacing = spacing; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setWordSpacing: function canvasGraphicsSetWordSpacing(spacing) { |
|
|
|
setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) { |
|
|
|
this.current.wordSpacing = spacing; |
|
|
|
this.current.wordSpacing = spacing; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setHScale: function canvasGraphicsSetHScale(scale) { |
|
|
|
setHScale: function CanvasGraphics_setHScale(scale) { |
|
|
|
this.current.textHScale = scale / 100; |
|
|
|
this.current.textHScale = scale / 100; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setLeading: function canvasGraphicsSetLeading(leading) { |
|
|
|
setLeading: function CanvasGraphics_setLeading(leading) { |
|
|
|
this.current.leading = -leading; |
|
|
|
this.current.leading = -leading; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setFont: function canvasGraphicsSetFont(fontRefName, size) { |
|
|
|
setFont: function CanvasGraphics_setFont(fontRefName, size) { |
|
|
|
var fontObj = this.objs.get(fontRefName); |
|
|
|
var fontObj = this.objs.get(fontRefName); |
|
|
|
var current = this.current; |
|
|
|
var current = this.current; |
|
|
|
|
|
|
|
|
|
|
@ -609,32 +609,32 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; |
|
|
|
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; |
|
|
|
this.ctx.font = rule; |
|
|
|
this.ctx.font = rule; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setTextRenderingMode: function canvasGraphicsSetTextRenderingMode(mode) { |
|
|
|
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) { |
|
|
|
if (mode >= TextRenderingMode.FILL_ADD_TO_PATH) |
|
|
|
if (mode >= TextRenderingMode.FILL_ADD_TO_PATH) |
|
|
|
TODO('unsupported text rendering mode: ' + mode); |
|
|
|
TODO('unsupported text rendering mode: ' + mode); |
|
|
|
this.current.textRenderingMode = mode; |
|
|
|
this.current.textRenderingMode = mode; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setTextRise: function canvasGraphicsSetTextRise(rise) { |
|
|
|
setTextRise: function CanvasGraphics_setTextRise(rise) { |
|
|
|
TODO('text rise: ' + rise); |
|
|
|
TODO('text rise: ' + rise); |
|
|
|
}, |
|
|
|
}, |
|
|
|
moveText: function canvasGraphicsMoveText(x, y) { |
|
|
|
moveText: function CanvasGraphics_moveText(x, y) { |
|
|
|
this.current.x = this.current.lineX += x; |
|
|
|
this.current.x = this.current.lineX += x; |
|
|
|
this.current.y = this.current.lineY += y; |
|
|
|
this.current.y = this.current.lineY += y; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setLeadingMoveText: function canvasGraphicsSetLeadingMoveText(x, y) { |
|
|
|
setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) { |
|
|
|
this.setLeading(-y); |
|
|
|
this.setLeading(-y); |
|
|
|
this.moveText(x, y); |
|
|
|
this.moveText(x, y); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setTextMatrix: function canvasGraphicsSetTextMatrix(a, b, c, d, e, f) { |
|
|
|
setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) { |
|
|
|
this.current.textMatrix = [a, b, c, d, e, f]; |
|
|
|
this.current.textMatrix = [a, b, c, d, e, f]; |
|
|
|
|
|
|
|
|
|
|
|
this.current.x = this.current.lineX = 0; |
|
|
|
this.current.x = this.current.lineX = 0; |
|
|
|
this.current.y = this.current.lineY = 0; |
|
|
|
this.current.y = this.current.lineY = 0; |
|
|
|
}, |
|
|
|
}, |
|
|
|
nextLine: function canvasGraphicsNextLine() { |
|
|
|
nextLine: function CanvasGraphics_nextLine() { |
|
|
|
this.moveText(0, this.current.leading); |
|
|
|
this.moveText(0, this.current.leading); |
|
|
|
}, |
|
|
|
}, |
|
|
|
applyTextTransforms: function canvasApplyTransforms() { |
|
|
|
applyTextTransforms: function CanvasGraphics_applyTextTransforms() { |
|
|
|
var ctx = this.ctx; |
|
|
|
var ctx = this.ctx; |
|
|
|
var current = this.current; |
|
|
|
var current = this.current; |
|
|
|
var textHScale = current.textHScale; |
|
|
|
var textHScale = current.textHScale; |
|
|
@ -646,7 +646,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
ctx.transform.apply(ctx, fontMatrix); |
|
|
|
ctx.transform.apply(ctx, fontMatrix); |
|
|
|
ctx.scale(textHScale, 1); |
|
|
|
ctx.scale(textHScale, 1); |
|
|
|
}, |
|
|
|
}, |
|
|
|
getTextGeometry: function canvasGetTextGeometry() { |
|
|
|
getTextGeometry: function CanvasGraphics_getTextGeometry() { |
|
|
|
var geometry = {}; |
|
|
|
var geometry = {}; |
|
|
|
var ctx = this.ctx; |
|
|
|
var ctx = this.ctx; |
|
|
|
var font = this.current.font; |
|
|
|
var font = this.current.font; |
|
|
@ -663,7 +663,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
return geometry; |
|
|
|
return geometry; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
showText: function canvasGraphicsShowText(str, skipTextSelection) { |
|
|
|
showText: function CanvasGraphics_showText(str, skipTextSelection) { |
|
|
|
var ctx = this.ctx; |
|
|
|
var ctx = this.ctx; |
|
|
|
var current = this.current; |
|
|
|
var current = this.current; |
|
|
|
var font = current.font; |
|
|
|
var font = current.font; |
|
|
@ -801,7 +801,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
|
|
|
|
|
|
|
|
return text; |
|
|
|
return text; |
|
|
|
}, |
|
|
|
}, |
|
|
|
showSpacedText: function canvasGraphicsShowSpacedText(arr) { |
|
|
|
showSpacedText: function CanvasGraphics_showSpacedText(arr) { |
|
|
|
var ctx = this.ctx; |
|
|
|
var ctx = this.ctx; |
|
|
|
var current = this.current; |
|
|
|
var current = this.current; |
|
|
|
var font = current.font; |
|
|
|
var font = current.font; |
|
|
@ -865,25 +865,25 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
if (textSelection) |
|
|
|
if (textSelection) |
|
|
|
this.textLayer.appendText(text, font.loadedName, fontSize); |
|
|
|
this.textLayer.appendText(text, font.loadedName, fontSize); |
|
|
|
}, |
|
|
|
}, |
|
|
|
nextLineShowText: function canvasGraphicsNextLineShowText(text) { |
|
|
|
nextLineShowText: function CanvasGraphics_nextLineShowText(text) { |
|
|
|
this.nextLine(); |
|
|
|
this.nextLine(); |
|
|
|
this.showText(text); |
|
|
|
this.showText(text); |
|
|
|
}, |
|
|
|
}, |
|
|
|
nextLineSetSpacingShowText: |
|
|
|
nextLineSetSpacingShowText: |
|
|
|
function canvasGraphicsNextLineSetSpacingShowText(wordSpacing, |
|
|
|
function CanvasGraphics_nextLineSetSpacingShowText(wordSpacing, |
|
|
|
charSpacing, |
|
|
|
charSpacing, |
|
|
|
text) { |
|
|
|
text) { |
|
|
|
this.setWordSpacing(wordSpacing); |
|
|
|
this.setWordSpacing(wordSpacing); |
|
|
|
this.setCharSpacing(charSpacing); |
|
|
|
this.setCharSpacing(charSpacing); |
|
|
|
this.nextLineShowText(text); |
|
|
|
this.nextLineShowText(text); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Type3 fonts
|
|
|
|
// Type3 fonts
|
|
|
|
setCharWidth: function canvasGraphicsSetCharWidth(xWidth, yWidth) { |
|
|
|
setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) { |
|
|
|
// We can safely ignore this since the width should be the same
|
|
|
|
// We can safely ignore this since the width should be the same
|
|
|
|
// as the width in the Widths array.
|
|
|
|
// as the width in the Widths array.
|
|
|
|
}, |
|
|
|
}, |
|
|
|
setCharWidthAndBounds: function canvasGraphicsSetCharWidthAndBounds(xWidth, |
|
|
|
setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, |
|
|
|
yWidth, |
|
|
|
yWidth, |
|
|
|
llx, |
|
|
|
llx, |
|
|
|
lly, |
|
|
|
lly, |
|
|
@ -897,20 +897,20 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Color
|
|
|
|
// Color
|
|
|
|
setStrokeColorSpace: function canvasGraphicsSetStrokeColorSpace(raw) { |
|
|
|
setStrokeColorSpace: function CanvasGraphics_setStrokeColorSpace(raw) { |
|
|
|
this.current.strokeColorSpace = ColorSpace.fromIR(raw); |
|
|
|
this.current.strokeColorSpace = ColorSpace.fromIR(raw); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setFillColorSpace: function canvasGraphicsSetFillColorSpace(raw) { |
|
|
|
setFillColorSpace: function CanvasGraphics_setFillColorSpace(raw) { |
|
|
|
this.current.fillColorSpace = ColorSpace.fromIR(raw); |
|
|
|
this.current.fillColorSpace = ColorSpace.fromIR(raw); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setStrokeColor: function canvasGraphicsSetStrokeColor(/*...*/) { |
|
|
|
setStrokeColor: function CanvasGraphics_setStrokeColor(/*...*/) { |
|
|
|
var cs = this.current.strokeColorSpace; |
|
|
|
var cs = this.current.strokeColorSpace; |
|
|
|
var rgbColor = cs.getRgb(arguments); |
|
|
|
var rgbColor = cs.getRgb(arguments); |
|
|
|
var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); |
|
|
|
var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); |
|
|
|
this.ctx.strokeStyle = color; |
|
|
|
this.ctx.strokeStyle = color; |
|
|
|
this.current.strokeColor = color; |
|
|
|
this.current.strokeColor = color; |
|
|
|
}, |
|
|
|
}, |
|
|
|
getColorN_Pattern: function canvasGraphicsGetColorN_Pattern(IR, cs) { |
|
|
|
getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR, cs) { |
|
|
|
if (IR[0] == 'TilingPattern') { |
|
|
|
if (IR[0] == 'TilingPattern') { |
|
|
|
var args = IR[1]; |
|
|
|
var args = IR[1]; |
|
|
|
var base = cs.base; |
|
|
|
var base = cs.base; |
|
|
@ -932,7 +932,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
return pattern; |
|
|
|
return pattern; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setStrokeColorN: function canvasGraphicsSetStrokeColorN(/*...*/) { |
|
|
|
setStrokeColorN: function CanvasGraphics_setStrokeColorN(/*...*/) { |
|
|
|
var cs = this.current.strokeColorSpace; |
|
|
|
var cs = this.current.strokeColorSpace; |
|
|
|
|
|
|
|
|
|
|
|
if (cs.name == 'Pattern') { |
|
|
|
if (cs.name == 'Pattern') { |
|
|
@ -941,14 +941,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.setStrokeColor.apply(this, arguments); |
|
|
|
this.setStrokeColor.apply(this, arguments); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
setFillColor: function canvasGraphicsSetFillColor(/*...*/) { |
|
|
|
setFillColor: function CanvasGraphics_setFillColor(/*...*/) { |
|
|
|
var cs = this.current.fillColorSpace; |
|
|
|
var cs = this.current.fillColorSpace; |
|
|
|
var rgbColor = cs.getRgb(arguments); |
|
|
|
var rgbColor = cs.getRgb(arguments); |
|
|
|
var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); |
|
|
|
var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); |
|
|
|
this.ctx.fillStyle = color; |
|
|
|
this.ctx.fillStyle = color; |
|
|
|
this.current.fillColor = color; |
|
|
|
this.current.fillColor = color; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setFillColorN: function canvasGraphicsSetFillColorN(/*...*/) { |
|
|
|
setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) { |
|
|
|
var cs = this.current.fillColorSpace; |
|
|
|
var cs = this.current.fillColorSpace; |
|
|
|
|
|
|
|
|
|
|
|
if (cs.name == 'Pattern') { |
|
|
|
if (cs.name == 'Pattern') { |
|
|
@ -957,7 +957,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.setFillColor.apply(this, arguments); |
|
|
|
this.setFillColor.apply(this, arguments); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
setStrokeGray: function canvasGraphicsSetStrokeGray(gray) { |
|
|
|
setStrokeGray: function CanvasGraphics_setStrokeGray(gray) { |
|
|
|
if (!(this.current.strokeColorSpace instanceof DeviceGrayCS)) |
|
|
|
if (!(this.current.strokeColorSpace instanceof DeviceGrayCS)) |
|
|
|
this.current.strokeColorSpace = new DeviceGrayCS(); |
|
|
|
this.current.strokeColorSpace = new DeviceGrayCS(); |
|
|
|
|
|
|
|
|
|
|
@ -965,7 +965,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.ctx.strokeStyle = color; |
|
|
|
this.ctx.strokeStyle = color; |
|
|
|
this.current.strokeColor = color; |
|
|
|
this.current.strokeColor = color; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setFillGray: function canvasGraphicsSetFillGray(gray) { |
|
|
|
setFillGray: function CanvasGraphics_setFillGray(gray) { |
|
|
|
if (!(this.current.fillColorSpace instanceof DeviceGrayCS)) |
|
|
|
if (!(this.current.fillColorSpace instanceof DeviceGrayCS)) |
|
|
|
this.current.fillColorSpace = new DeviceGrayCS(); |
|
|
|
this.current.fillColorSpace = new DeviceGrayCS(); |
|
|
|
|
|
|
|
|
|
|
@ -973,7 +973,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.ctx.fillStyle = color; |
|
|
|
this.ctx.fillStyle = color; |
|
|
|
this.current.fillColor = color; |
|
|
|
this.current.fillColor = color; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setStrokeRGBColor: function canvasGraphicsSetStrokeRGBColor(r, g, b) { |
|
|
|
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) { |
|
|
|
if (!(this.current.strokeColorSpace instanceof DeviceRgbCS)) |
|
|
|
if (!(this.current.strokeColorSpace instanceof DeviceRgbCS)) |
|
|
|
this.current.strokeColorSpace = new DeviceRgbCS(); |
|
|
|
this.current.strokeColorSpace = new DeviceRgbCS(); |
|
|
|
|
|
|
|
|
|
|
@ -981,7 +981,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.ctx.strokeStyle = color; |
|
|
|
this.ctx.strokeStyle = color; |
|
|
|
this.current.strokeColor = color; |
|
|
|
this.current.strokeColor = color; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setFillRGBColor: function canvasGraphicsSetFillRGBColor(r, g, b) { |
|
|
|
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) { |
|
|
|
if (!(this.current.fillColorSpace instanceof DeviceRgbCS)) |
|
|
|
if (!(this.current.fillColorSpace instanceof DeviceRgbCS)) |
|
|
|
this.current.fillColorSpace = new DeviceRgbCS(); |
|
|
|
this.current.fillColorSpace = new DeviceRgbCS(); |
|
|
|
|
|
|
|
|
|
|
@ -989,7 +989,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.ctx.fillStyle = color; |
|
|
|
this.ctx.fillStyle = color; |
|
|
|
this.current.fillColor = color; |
|
|
|
this.current.fillColor = color; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setStrokeCMYKColor: function canvasGraphicsSetStrokeCMYKColor(c, m, y, k) { |
|
|
|
setStrokeCMYKColor: function CanvasGraphics_setStrokeCMYKColor(c, m, y, k) { |
|
|
|
if (!(this.current.strokeColorSpace instanceof DeviceCmykCS)) |
|
|
|
if (!(this.current.strokeColorSpace instanceof DeviceCmykCS)) |
|
|
|
this.current.strokeColorSpace = new DeviceCmykCS(); |
|
|
|
this.current.strokeColorSpace = new DeviceCmykCS(); |
|
|
|
|
|
|
|
|
|
|
@ -997,7 +997,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.ctx.strokeStyle = color; |
|
|
|
this.ctx.strokeStyle = color; |
|
|
|
this.current.strokeColor = color; |
|
|
|
this.current.strokeColor = color; |
|
|
|
}, |
|
|
|
}, |
|
|
|
setFillCMYKColor: function canvasGraphicsSetFillCMYKColor(c, m, y, k) { |
|
|
|
setFillCMYKColor: function CanvasGraphics_setFillCMYKColor(c, m, y, k) { |
|
|
|
if (!(this.current.fillColorSpace instanceof DeviceCmykCS)) |
|
|
|
if (!(this.current.fillColorSpace instanceof DeviceCmykCS)) |
|
|
|
this.current.fillColorSpace = new DeviceCmykCS(); |
|
|
|
this.current.fillColorSpace = new DeviceCmykCS(); |
|
|
|
|
|
|
|
|
|
|
@ -1006,7 +1006,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.current.fillColor = color; |
|
|
|
this.current.fillColor = color; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
shadingFill: function canvasGraphicsShadingFill(patternIR) { |
|
|
|
shadingFill: function CanvasGraphics_shadingFill(patternIR) { |
|
|
|
var ctx = this.ctx; |
|
|
|
var ctx = this.ctx; |
|
|
|
|
|
|
|
|
|
|
|
this.save(); |
|
|
|
this.save(); |
|
|
@ -1043,14 +1043,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Images
|
|
|
|
// Images
|
|
|
|
beginInlineImage: function canvasGraphicsBeginInlineImage() { |
|
|
|
beginInlineImage: function CanvasGraphics_beginInlineImage() { |
|
|
|
error('Should not call beginInlineImage'); |
|
|
|
error('Should not call beginInlineImage'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
beginImageData: function canvasGraphicsBeginImageData() { |
|
|
|
beginImageData: function CanvasGraphics_beginImageData() { |
|
|
|
error('Should not call beginImageData'); |
|
|
|
error('Should not call beginImageData'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
paintFormXObjectBegin: function canvasGraphicsPaintFormXObjectBegin(matrix, |
|
|
|
paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, |
|
|
|
bbox) { |
|
|
|
bbox) { |
|
|
|
this.save(); |
|
|
|
this.save(); |
|
|
|
|
|
|
|
|
|
|
@ -1066,11 +1066,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
paintFormXObjectEnd: function canvasGraphicsPaintFormXObjectEnd() { |
|
|
|
paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() { |
|
|
|
this.restore(); |
|
|
|
this.restore(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
paintJpegXObject: function canvasGraphicsPaintJpegXObject(objId, w, h) { |
|
|
|
paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) { |
|
|
|
var domImage = this.objs.get(objId); |
|
|
|
var domImage = this.objs.get(objId); |
|
|
|
if (!domImage) { |
|
|
|
if (!domImage) { |
|
|
|
error('Dependent image isn\'t ready yet'); |
|
|
|
error('Dependent image isn\'t ready yet'); |
|
|
@ -1088,7 +1088,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.restore(); |
|
|
|
this.restore(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
paintImageMaskXObject: function canvasGraphicsPaintImageMaskXObject( |
|
|
|
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject( |
|
|
|
imgArray, inverseDecode, width, height) { |
|
|
|
imgArray, inverseDecode, width, height) { |
|
|
|
function applyStencilMask(buffer, inverseDecode) { |
|
|
|
function applyStencilMask(buffer, inverseDecode) { |
|
|
|
var imgArrayPos = 0; |
|
|
|
var imgArrayPos = 0; |
|
|
@ -1137,7 +1137,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.restore(); |
|
|
|
this.restore(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
paintImageXObject: function canvasGraphicsPaintImageXObject(objId) { |
|
|
|
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) { |
|
|
|
var imgData = this.objs.get(objId); |
|
|
|
var imgData = this.objs.get(objId); |
|
|
|
if (!imgData) |
|
|
|
if (!imgData) |
|
|
|
error('Dependent image isn\'t ready yet'); |
|
|
|
error('Dependent image isn\'t ready yet'); |
|
|
@ -1157,41 +1157,41 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
this.restore(); |
|
|
|
this.restore(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
putBinaryImageData: function canvasPutBinaryImageData() { |
|
|
|
putBinaryImageData: function CanvasGraphics_putBinaryImageData() { |
|
|
|
//
|
|
|
|
//
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Marked content
|
|
|
|
// Marked content
|
|
|
|
|
|
|
|
|
|
|
|
markPoint: function canvasGraphicsMarkPoint(tag) { |
|
|
|
markPoint: function CanvasGraphics_markPoint(tag) { |
|
|
|
TODO('Marked content'); |
|
|
|
TODO('Marked content'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
markPointProps: function canvasGraphicsMarkPointProps(tag, properties) { |
|
|
|
markPointProps: function CanvasGraphics_markPointProps(tag, properties) { |
|
|
|
TODO('Marked content'); |
|
|
|
TODO('Marked content'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
beginMarkedContent: function canvasGraphicsBeginMarkedContent(tag) { |
|
|
|
beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) { |
|
|
|
TODO('Marked content'); |
|
|
|
TODO('Marked content'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
beginMarkedContentProps: |
|
|
|
beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps( |
|
|
|
function canvasGraphicsBeginMarkedContentProps(tag, properties) { |
|
|
|
tag, properties) { |
|
|
|
TODO('Marked content'); |
|
|
|
TODO('Marked content'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
endMarkedContent: function canvasGraphicsEndMarkedContent() { |
|
|
|
endMarkedContent: function CanvasGraphics_endMarkedContent() { |
|
|
|
TODO('Marked content'); |
|
|
|
TODO('Marked content'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Compatibility
|
|
|
|
// Compatibility
|
|
|
|
|
|
|
|
|
|
|
|
beginCompat: function canvasGraphicsBeginCompat() { |
|
|
|
beginCompat: function CanvasGraphics_beginCompat() { |
|
|
|
TODO('ignore undefined operators (should we do that anyway?)'); |
|
|
|
TODO('ignore undefined operators (should we do that anyway?)'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
endCompat: function canvasGraphicsEndCompat() { |
|
|
|
endCompat: function CanvasGraphics_endCompat() { |
|
|
|
TODO('stop ignoring undefined operators'); |
|
|
|
TODO('stop ignoring undefined operators'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Helper functions
|
|
|
|
// Helper functions
|
|
|
|
|
|
|
|
|
|
|
|
consumePath: function canvasGraphicsConsumePath() { |
|
|
|
consumePath: function CanvasGraphics_consumePath() { |
|
|
|
if (this.pendingClip) { |
|
|
|
if (this.pendingClip) { |
|
|
|
var savedFillRule = null; |
|
|
|
var savedFillRule = null; |
|
|
|
if (this.pendingClip == EO_CLIP) |
|
|
|
if (this.pendingClip == EO_CLIP) |
|
|
@ -1208,15 +1208,15 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { |
|
|
|
// We generally keep the canvas context set for
|
|
|
|
// We generally keep the canvas context set for
|
|
|
|
// nonzero-winding, and just set evenodd for the operations
|
|
|
|
// nonzero-winding, and just set evenodd for the operations
|
|
|
|
// that need them.
|
|
|
|
// that need them.
|
|
|
|
setEOFillRule: function canvasGraphicsSetEOFillRule() { |
|
|
|
setEOFillRule: function CanvasGraphics_setEOFillRule() { |
|
|
|
var savedFillRule = this.ctx.mozFillRule; |
|
|
|
var savedFillRule = this.ctx.mozFillRule; |
|
|
|
this.ctx.mozFillRule = 'evenodd'; |
|
|
|
this.ctx.mozFillRule = 'evenodd'; |
|
|
|
return savedFillRule; |
|
|
|
return savedFillRule; |
|
|
|
}, |
|
|
|
}, |
|
|
|
restoreFillRule: function canvasGraphicsRestoreFillRule(rule) { |
|
|
|
restoreFillRule: function CanvasGraphics_restoreFillRule(rule) { |
|
|
|
this.ctx.mozFillRule = rule; |
|
|
|
this.ctx.mozFillRule = rule; |
|
|
|
}, |
|
|
|
}, |
|
|
|
getSinglePixelWidth: function getSinglePixelWidth(scale) { |
|
|
|
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) { |
|
|
|
var inverse = this.ctx.mozCurrentTransformInverse; |
|
|
|
var inverse = this.ctx.mozCurrentTransformInverse; |
|
|
|
return Math.abs(inverse[0] + inverse[2]); |
|
|
|
return Math.abs(inverse[0] + inverse[2]); |
|
|
|
} |
|
|
|
} |
|
|
|