From: Chris Jones Date: Wed, 15 Jun 2011 19:42:48 +0000 (-0700) Subject: Merge branch 'master' of github.com:andreasgal/pdf.js X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=672741bc5cd4c7676d62c0ee3d0bc9fd87d4d2f1;p=pdf.js.git Merge branch 'master' of github.com:andreasgal/pdf.js --- 672741bc5cd4c7676d62c0ee3d0bc9fd87d4d2f1 diff --cc pdf.js index 517b2b2,2df975c..10e6611 --- a/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);