From: sbarman Date: Tue, 28 Jun 2011 21:23:56 +0000 (-0700) Subject: Merge branch 'master' into colorspace X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5a1a35813bfa181e144b8499487bfbd32218c808;p=pdf.js.git Merge branch 'master' into colorspace Conflicts: pdf.js --- 5a1a35813bfa181e144b8499487bfbd32218c808 diff --cc pdf.js index 8b9fefb,3179f42..bdb88a4 --- a/pdf.js +++ b/pdf.js @@@ -2230,8 -3255,43 +3255,46 @@@ var Encodings = } }; + var IDENTITY_MATRIX = [ 1, 0, 0, 1, 0, 0 ]; + + // contexts store most of the state we need natively. + // However, PDF needs a bit more state, which we store here. + var CanvasExtraState = (function() { + function constructor() { + // Are soft masks and alpha values shapes or opacities? + this.alphaIsShape = false; + this.fontSize = 0; + this.textMatrix = IDENTITY_MATRIX; + this.leading = 0; + this.colorSpace = null; + // 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.charSpace = 0; + this.wordSpace = 0; + this.textHScale = 100; ++ // Color spaces ++ this.fillColorSpace = null; ++ this.strokeColorSpace = null; + } + constructor.prototype = { + }; + return constructor; + })(); + + function ScratchCanvas(width, height) { + var canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + return canvas; + } + var CanvasGraphics = (function() { - function constructor(canvasCtx) { + function constructor(canvasCtx, imageCanvas) { this.ctx = canvasCtx; this.current = new CanvasExtraState(); this.stateStack = [ ]; @@@ -3374,15 -4318,13 +4321,20 @@@ var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0; return "rgb("+ ri +","+ gi +","+ bi +")"; }, + makeCssCmyk: function(c, m, y, k) { + // while waiting on CSS's cmyk()... http://www.ilkeratalay.com/colorspacesfaq.php#rgb + var ri = (255 * (1 - Math.min(1, c * (1 - k) + k))) | 0; + var gi = (255 * (1 - Math.min(1, m * (1 - k) + k))) | 0; + var bi = (255 * (1 - Math.min(1, y * (1 - k) + k))) | 0; + return "rgb("+ ri +","+ gi +","+ bi +")"; + }, + getColorSpaceObj(colorSpace) { + if (IsName(colorSpace)) { + var name = colorSpace.name; + } else if (IsArray(colorSpace)) { + var name = colorSpace[0]; + } - } - + }, // We generally keep the canvas context set for // nonzero-winding, and just set evenodd for the operations // that need them.