]> git.parisson.com Git - pdf.js.git/commitdiff
interpolated functions
authorsbarman <sbarman@L3CWZ5T.(none)>
Mon, 11 Jul 2011 21:09:16 +0000 (14:09 -0700)
committersbarman <sbarman@L3CWZ5T.(none)>
Mon, 11 Jul 2011 21:09:16 +0000 (14:09 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index d03bc745d870b2179f9c35e394ca33e34c8a1ead..a96ea8742530bc8c4d59a4f5930ffa50c63612d5 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -5365,9 +5365,25 @@ var PDFFunction = (function() {
       }
       return array;
     },
-    constructInterpolated: function() {
-      TODO('unhandled type of function');
-      this.func = function () { return [ 255, 105, 180 ]; }
+    constructInterpolated: function(str, dict) {
+      var c0 = dict.get('C0') || [0];
+      var c1 = dict.get('C1') || [1];
+      var n = dict.get('N');
+      
+      var length = c0.length;
+      var diff = [];
+      for (var i = 0; i < length; ++i)
+        diff.push(c1[i] - c0[i]);
+
+      this.func = function (args) {
+        var x = args[0];
+
+        var out = [];
+        for (var j = 0; j < length; ++j)
+          out.push(c0[j] + (x^n * diff[i]));
+
+        return out;
+      }
     },
     constructStiched: function() {
       TODO('unhandled type of function');