From: Julian Viereck Date: Wed, 7 Sep 2011 20:42:38 +0000 (-0700) Subject: Add some comments + fix getColorN_IR_Pattern X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5bfa9e4f3b9f34369def38d0aa9aa5140f654f97;p=pdf.js.git Add some comments + fix getColorN_IR_Pattern --- diff --git a/pdf.js b/pdf.js index 1407cd9..7af3e64 100644 --- a/pdf.js +++ b/pdf.js @@ -4234,21 +4234,22 @@ var PartialEvaluator = (function() { var dict = IsStream(pattern) ? pattern.dict : pattern; var typeNum = dict.get('PatternType'); - // Type1 is TilingPattern, Type2 is ShadingPattern. + // Type1 is TilingPattern if (typeNum == 1) { // Create an IR of the pattern code. var codeIR = this.evalRaw(pattern, xref, dict.get('Resources'), fonts); args = TilingPattern.getIR(codeIR, dict); - - //patternName.code = this.evalRaw(pattern, xref, - // dict.get('Resources'), fonts); - } else { + } + // Type2 is ShadingPattern. + else if (typeNum == 2) { var shading = xref.fetchIfRef(dict.get('Shading')); var matrix = dict.get('Matrix'); var pattern = Pattern.parseShading(shading, matrix, xref, res, null /*ctx*/); args = pattern.getPatternRaw(); + } else { + error("Unkown PatternType " + typeNum); } } } @@ -5277,7 +5278,7 @@ var CanvasGraphics = (function() { this.setStrokeColor.apply(this, arguments); } }, - getColorN_IR_Pattern: function(IR) { + getColorN_IR_Pattern: function(IR, cs) { if (IR[0] == "TilingPatternIR") { // First, build the `color` var like it's done in the // Pattern.prototype.parse function. @@ -5306,7 +5307,7 @@ var CanvasGraphics = (function() { var cs = this.current.strokeColorSpace; if (cs.name == 'Pattern') { - this.current.strokeColor = this.getColorN_IR_Pattern(arguments); + this.current.strokeColor = this.getColorN_IR_Pattern(arguments, cs); } else { this.setStrokeColor.apply(this, arguments); } @@ -5333,7 +5334,7 @@ var CanvasGraphics = (function() { var cs = this.current.fillColorSpace; if (cs.name == 'Pattern') { - this.current.fillColor = this.getColorN_IR_Pattern(arguments); + this.current.fillColor = this.getColorN_IR_Pattern(arguments, cs); } else { this.setFillColor.apply(this, arguments); }