Comparing version 2.0.0-alpha.4 to 2.0.0-alpha.5
@@ -68,19 +68,2 @@ 'use strict'; | ||
/** | ||
* Create a synchronous `PNGStream` for `this` canvas. | ||
* | ||
* @param {Object} options | ||
* @param {Uint8ClampedArray} options.palette Provide for indexed PNG encoding. | ||
* entries should be R-G-B-A values. | ||
* @param {Number} options.backgroundIndex Optional index of background color | ||
* for indexed PNGs. Defaults to 0. | ||
* @return {PNGStream} | ||
* @api public | ||
*/ | ||
Canvas.prototype.syncPNGStream = | ||
Canvas.prototype.createSyncPNGStream = function(options){ | ||
return new PNGStream(this, true, options); | ||
}; | ||
/** | ||
* Create a `PDFStream` for `this` canvas. | ||
@@ -98,14 +81,2 @@ * | ||
/** | ||
* Create a synchronous `PDFStream` for `this` canvas. | ||
* | ||
* @return {PDFStream} | ||
* @api public | ||
*/ | ||
Canvas.prototype.syncPDFStream = | ||
Canvas.prototype.createSyncPDFStream = function(){ | ||
return new PDFStream(this, true); | ||
}; | ||
/** | ||
* Create a `JPEGStream` for `this` canvas. | ||
@@ -120,15 +91,2 @@ * | ||
Canvas.prototype.createJPEGStream = function(options){ | ||
return this.createSyncJPEGStream(options); | ||
}; | ||
/** | ||
* Create a synchronous `JPEGStream` for `this` canvas. | ||
* | ||
* @param {Object} options | ||
* @return {JPEGStream} | ||
* @api public | ||
*/ | ||
Canvas.prototype.syncJPEGStream = | ||
Canvas.prototype.createSyncJPEGStream = function(options){ | ||
options = options || {}; | ||
@@ -135,0 +93,0 @@ // Don't allow the buffer size to exceed the size of the canvas (#674) |
@@ -29,7 +29,6 @@ 'use strict'; | ||
* @param {Canvas} canvas | ||
* @param {Boolean} sync | ||
* @api public | ||
*/ | ||
var JPEGStream = module.exports = function JPEGStream(canvas, options, sync) { | ||
var JPEGStream = module.exports = function JPEGStream(canvas, options) { | ||
if (!(this instanceof JPEGStream)) { | ||
@@ -42,12 +41,4 @@ throw new TypeError("Class constructors cannot be invoked without 'new'"); | ||
var self = this; | ||
var method = sync | ||
? 'streamJPEGSync' | ||
: 'streamJPEG'; | ||
this.options = options; | ||
this.sync = sync; | ||
this.canvas = canvas; | ||
// TODO: implement async | ||
if ('streamJPEG' == method) method = 'streamJPEGSync'; | ||
this.method = method; | ||
}; | ||
@@ -68,3 +59,3 @@ | ||
var progressive = this.options.progressive; | ||
self.canvas[method](bufsize, quality, progressive, function(err, chunk){ | ||
self.canvas.streamJPEGSync(bufsize, quality, progressive, function(err, chunk){ | ||
if (err) { | ||
@@ -71,0 +62,0 @@ self.emit('error', err); |
@@ -27,7 +27,6 @@ 'use strict'; | ||
* @param {Canvas} canvas | ||
* @param {Boolean} sync | ||
* @api public | ||
*/ | ||
var PDFStream = module.exports = function PDFStream(canvas, sync) { | ||
var PDFStream = module.exports = function PDFStream(canvas) { | ||
if (!(this instanceof PDFStream)) { | ||
@@ -39,12 +38,3 @@ throw new TypeError("Class constructors cannot be invoked without 'new'"); | ||
var self = this | ||
, method = sync | ||
? 'streamPDFSync' | ||
: 'streamPDF'; | ||
this.sync = sync; | ||
this.canvas = canvas; | ||
// TODO: implement async | ||
if ('streamPDF' == method) method = 'streamPDFSync'; | ||
this.method = method; | ||
}; | ||
@@ -61,3 +51,3 @@ | ||
var self = this; | ||
self.canvas[self.method](function(err, chunk, len){ | ||
self.canvas.streamPDFSync(function(err, chunk, len){ | ||
if (err) { | ||
@@ -64,0 +54,0 @@ self.emit('error', err); |
@@ -29,3 +29,2 @@ 'use strict'; | ||
* @param {Canvas} canvas | ||
* @param {Boolean} sync | ||
* @param {Object} options | ||
@@ -39,3 +38,3 @@ * @param {Uint8ClampedArray} options.palette Provide for indexed PNG encoding. | ||
var PNGStream = module.exports = function PNGStream(canvas, sync, options) { | ||
var PNGStream = module.exports = function PNGStream(canvas, options) { | ||
if (!(this instanceof PNGStream)) { | ||
@@ -48,12 +47,4 @@ throw new TypeError("Class constructors cannot be invoked without 'new'"); | ||
var self = this; | ||
var method = sync | ||
? 'streamPNGSync' | ||
: 'streamPNG'; | ||
this.sync = sync; | ||
this.canvas = canvas; | ||
this.options = options || {}; | ||
// TODO: implement async | ||
if ('streamPNG' === method) method = 'streamPNGSync'; | ||
this.method = method; | ||
}; | ||
@@ -70,3 +61,3 @@ | ||
var self = this; | ||
self.canvas[self.method](function(err, chunk, len){ | ||
self.canvas.streamPNGSync(function(err, chunk, len){ | ||
if (err) { | ||
@@ -73,0 +64,0 @@ self.emit('error', err); |
{ | ||
"name": "canvas", | ||
"description": "Canvas graphics API backed by Cairo", | ||
"version": "2.0.0-alpha.4", | ||
"version": "2.0.0-alpha.5", | ||
"author": "TJ Holowaychuk <tj@learnboost.com>", | ||
@@ -6,0 +6,0 @@ "browser": "browser.js", |
@@ -141,4 +141,2 @@ # node-canvas | ||
Currently _only_ sync streaming is supported, however we plan on supporting async streaming as well (of course :) ). Until then the `Canvas#toBuffer(callback)` alternative is async utilizing `eio_custom()`. | ||
To encode indexed PNGs from canvases with `pixelFormat: 'A8'` or `'A1'`, provide an options object: | ||
@@ -145,0 +143,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
267060
932
473