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);