]> git.parisson.com Git - pdf.js.git/commitdiff
Merge branch 'master' of github.com:andreasgal/pdf.js
authorChris Jones <jones.chris.g@gmail.com>
Wed, 15 Jun 2011 19:42:48 +0000 (12:42 -0700)
committerChris Jones <jones.chris.g@gmail.com>
Wed, 15 Jun 2011 19:42:48 +0000 (12:42 -0700)
1  2 
pdf.js

diff --cc pdf.js
index 517b2b27cf80cb98c712a8d05ae2e4861f7b59c4,2df975c734cf6337ded69fee81704fe72d0055c1..10e661129210b8c658deaa584d98a29628ba8cb6
--- 1/pdf.js
--- 2/pdf.js
+++ b/pdf.js
@@@ -2111,30 -2031,32 +2122,41 @@@ var CanvasGraphics = (function() 
              if (sh.has("Extend")) {
                  var extendArr = sh.get("Extend");
                  extendStart = extendArr[0], extendEnd = extendArr[1];
+                 TODO("Support extend");
              }
-             var fn = sh.get("Function");
-             fn = this.xref.fetchIfRef(fn);
+             var fnObj = sh.get("Function");
+             fnObj = this.xref.fetchIfRef(fnObj);
+             if (IsArray(fnObj))
+                 error("No support for array of functions");
+             else if (!IsPDFFunction(fnObj))
+                 error("Invalid function");
+             fn = new PDFFunction(this.xref, fnObj);
  
              var gradient = this.ctx.createLinearGradient(x0, y0, x1, y1);
-             gradient.addColorStop(0, 'rgb(0,0,255)');
-             gradient.addColorStop(1, 'rgb(0,255,0)');
+             var step = (t1 - t0) / 10;
+             
+             for (var i = t0; i <= t1; i += step) {
+                 var c = fn.func([i]);
+                 gradient.addColorStop(i, this.makeCssRgb.apply(this, c));
+             }
  
              this.ctx.fillStyle = gradient;
-             this.ctx.fill();
-             this.consumePath();
+             
+             // HACK to draw the gradient onto an infinite rectangle.
+             // PDF gradients are drawn across the entire image while
+             // Canvas only allows gradients to be drawn in a rectangle
+             this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
          },
  
 +        // Images
 +        beginInlineImage: function() {
 +            TODO("inline images");
 +            error("(Stream will not be parsed properly, bailing now)");
 +            // Like an inline stream:
 +            //  - key/value pairs up to Cmd(ID)
 +            //  - then image data up to Cmd(EI)
 +        },
 +
          // XObjects
          paintXObject: function(obj) {
              var xobj = this.xobjs.get(obj.name);