]> git.parisson.com Git - pdf.js.git/commitdiff
Move getting the Pattern from IR form out and make setStrokeColorN_IR work
authorJulian Viereck <julian.viereck@gmail.com>
Wed, 7 Sep 2011 20:38:52 +0000 (13:38 -0700)
committerJulian Viereck <julian.viereck@gmail.com>
Thu, 15 Sep 2011 15:21:23 +0000 (08:21 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index a7fe1e29c1e37b9e1419d0d604ab021cedd3cf94..1407cd9b41d90c68c9639bccfc9f043c8679715a 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -4222,7 +4222,8 @@ var PartialEvaluator = (function() {
           // TODO figure out how to type-check vararg functions
 
           if ((cmd == 'SCN' || cmd == 'scn') && !args[args.length - 1].code) {
-            fn = "setFillColorN_IR";
+            // Use the IR version for setStroke/FillColorN.
+            fn += '_IR';
             
             // compile tiling patterns
             var patternName = args[args.length - 1];
@@ -5276,6 +5277,41 @@ var CanvasGraphics = (function() {
         this.setStrokeColor.apply(this, arguments);
       }
     },
+    getColorN_IR_Pattern: function(IR) {
+      if (IR[0] == "TilingPatternIR") {
+        // First, build the `color` var like it's done in the
+        // Pattern.prototype.parse function.
+        var base = cs.base;
+        var color;
+        if (base) {
+          var baseComps = base.numComps;
+
+          color = [];
+          for (var i = 0; i < baseComps; ++i)
+            color.push(args[i]);
+
+          color = base.getRgb(color);
+        }
+
+        // Build the pattern based on the IR data.
+        var pattern = new TilingPatternIR(IR, color, this.ctx);
+      } else if (IR[0] == "RadialAxialShading") {
+        var pattern = Pattern.shadingFromRaw(this.ctx, IR); 
+      } else {
+        throw "Unkown IR type";
+      }
+      return pattern; 
+    },
+    setStrokeColorN_IR: function(/*...*/) {
+      var cs = this.current.strokeColorSpace;
+
+      if (cs.name == 'Pattern') {
+        this.current.strokeColor = this.getColorN_IR_Pattern(arguments);
+      } else {
+        this.setStrokeColor.apply(this, arguments);
+      }
+      
+    },
     setFillColor: function(/*...*/) {
       var cs = this.current.fillColorSpace;
       var color = cs.getRgb(arguments);
@@ -5297,30 +5333,7 @@ var CanvasGraphics = (function() {
       var cs = this.current.fillColorSpace;
 
       if (cs.name == 'Pattern') {
-        var IR = arguments;
-        if (IR[0] == "TilingPatternIR") {
-          // First, build the `color` var like it's done in the
-          // Pattern.prototype.parse function.
-          var base = cs.base;
-          var color;
-          if (base) {
-            var baseComps = base.numComps;
-
-            color = [];
-            for (var i = 0; i < baseComps; ++i)
-              color.push(args[i]);
-
-            color = base.getRgb(color);
-          }
-
-          // Build the pattern based on the IR data.
-          var pattern = new TilingPatternIR(IR, color, this.ctx);
-        } else if (IR[0] == "RadialAxialShading") {
-          var pattern = Pattern.shadingFromRaw(this.ctx, IR); 
-        } else {
-          throw "Unkown IR type";
-        }
-        this.current.fillColor = pattern;
+        this.current.fillColor = this.getColorN_IR_Pattern(arguments);
       } else {
         this.setFillColor.apply(this, arguments);
       }