mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Prebuilt module for commit 6c5f1dc671
This commit is contained in:
parent
cb95b131a0
commit
579179a517
7 changed files with 23 additions and 18 deletions
2
dist/docs/assets/js/paper.js
vendored
2
dist/docs/assets/js/paper.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Wed Oct 4 21:43:56 2017 +0200
|
||||
* Date: Wed Oct 4 22:39:19 2017 +0200
|
||||
*
|
||||
***
|
||||
*
|
||||
|
|
17
dist/node/canvas.js
vendored
17
dist/node/canvas.js
vendored
|
@ -13,7 +13,7 @@
|
|||
// Add some useful extensions to HTMLCanvasElement:
|
||||
// - HTMLCanvasElement#type, so we can switch to a PDF canvas
|
||||
// - Various Node-Canvas methods, routed through from HTMLCanvasElement:
|
||||
// toBuffer, pngStream, createPNGStream, jpgStream, createJPGStream
|
||||
// toBuffer, pngStream, createPNGStream, jpegStream, createJPEGStream
|
||||
|
||||
module.exports = function(self, requireName) {
|
||||
var Canvas;
|
||||
|
@ -55,11 +55,12 @@ module.exports = function(self, requireName) {
|
|||
});
|
||||
|
||||
// Extend HTMLCanvasElement with useful methods from the underlying Canvas:
|
||||
['toBuffer', 'pngStream', 'createPNGStream', 'jpgStream', 'createJPGStream']
|
||||
.forEach(function(key) {
|
||||
HTMLCanvasElement.prototype[key] = function() {
|
||||
var canvas = idlUtils.implForWrapper(this)._canvas;
|
||||
return canvas[key].apply(canvas, arguments);
|
||||
};
|
||||
});
|
||||
var methods = ['toBuffer', 'pngStream', 'createPNGStream', 'jpegStream',
|
||||
'createJPEGStream'];
|
||||
methods.forEach(function(key) {
|
||||
HTMLCanvasElement.prototype[key] = function() {
|
||||
var canvas = idlUtils.implForWrapper(this)._canvas;
|
||||
return canvas[key].apply(canvas, arguments);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
14
dist/node/extend.js
vendored
14
dist/node/extend.js
vendored
|
@ -67,7 +67,7 @@ module.exports = function(paper) {
|
|||
},
|
||||
|
||||
/**
|
||||
* @deprecated use use {@link #createCanvas(width, height)} instead.
|
||||
* @deprecated, use use {@link #createCanvas(width, height)} instead.
|
||||
*/
|
||||
Canvas: '#createCanvas'
|
||||
});
|
||||
|
@ -87,9 +87,12 @@ module.exports = function(paper) {
|
|||
fps: 30,
|
||||
prefix: 'frame-',
|
||||
amount: 1,
|
||||
format: 'png' // Supported: 'png' or 'jpeg'
|
||||
}, options);
|
||||
if (!options.directory)
|
||||
throw new Error('Missing options.directory');
|
||||
if (options.format && !/^(jpeg|png)$/.test(options.format))
|
||||
throw new Error('Unsupported format. Use "png" or "jpeg"');
|
||||
var view = this,
|
||||
count = 0,
|
||||
frameDuration = 1 / options.fps,
|
||||
|
@ -108,8 +111,9 @@ module.exports = function(paper) {
|
|||
time: frameDuration * count,
|
||||
count: count
|
||||
}));
|
||||
var file = path.join(options.directory, options.prefix +
|
||||
(paddedStr + count).slice(-padding) + '.png');
|
||||
var file = path.join(options.directory,
|
||||
options.prefix + (paddedStr + count).slice(-padding)
|
||||
+ '.' + options.format);
|
||||
var out = view.exportImage(file, function() {
|
||||
// Once the file has been closed, export the next fame:
|
||||
var then = Date.now();
|
||||
|
@ -140,8 +144,8 @@ module.exports = function(paper) {
|
|||
exportImage: function(path, callback) {
|
||||
this.update();
|
||||
var out = fs.createWriteStream(path),
|
||||
stream = this._element.createPNGStream();
|
||||
// Pipe the png stream to the write stream:
|
||||
format = /\.jp(e?)g$/.test(path) ? 'jpeg' : 'png'
|
||||
stream = this._element[format + 'Stream']();
|
||||
stream.pipe(out);
|
||||
if (callback) {
|
||||
out.on('close', callback);
|
||||
|
|
2
dist/paper-core.js
vendored
2
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Wed Oct 4 21:43:56 2017 +0200
|
||||
* Date: Wed Oct 4 22:39:19 2017 +0200
|
||||
*
|
||||
***
|
||||
*
|
||||
|
|
2
dist/paper-core.min.js
vendored
2
dist/paper-core.min.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Wed Oct 4 21:43:56 2017 +0200
|
||||
* Date: Wed Oct 4 22:39:19 2017 +0200
|
||||
*
|
||||
***
|
||||
*
|
||||
|
|
2
dist/paper-full.js
vendored
2
dist/paper-full.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Wed Oct 4 21:43:56 2017 +0200
|
||||
* Date: Wed Oct 4 22:39:19 2017 +0200
|
||||
*
|
||||
***
|
||||
*
|
||||
|
|
2
dist/paper-full.min.js
vendored
2
dist/paper-full.min.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Wed Oct 4 21:43:56 2017 +0200
|
||||
* Date: Wed Oct 4 22:39:19 2017 +0200
|
||||
*
|
||||
***
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue