mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -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.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Wed Oct 4 21:43:56 2017 +0200
|
* Date: Wed Oct 4 22:39:19 2017 +0200
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
|
7
dist/node/canvas.js
vendored
7
dist/node/canvas.js
vendored
|
@ -13,7 +13,7 @@
|
||||||
// Add some useful extensions to HTMLCanvasElement:
|
// Add some useful extensions to HTMLCanvasElement:
|
||||||
// - HTMLCanvasElement#type, so we can switch to a PDF canvas
|
// - HTMLCanvasElement#type, so we can switch to a PDF canvas
|
||||||
// - Various Node-Canvas methods, routed through from HTMLCanvasElement:
|
// - Various Node-Canvas methods, routed through from HTMLCanvasElement:
|
||||||
// toBuffer, pngStream, createPNGStream, jpgStream, createJPGStream
|
// toBuffer, pngStream, createPNGStream, jpegStream, createJPEGStream
|
||||||
|
|
||||||
module.exports = function(self, requireName) {
|
module.exports = function(self, requireName) {
|
||||||
var Canvas;
|
var Canvas;
|
||||||
|
@ -55,8 +55,9 @@ module.exports = function(self, requireName) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Extend HTMLCanvasElement with useful methods from the underlying Canvas:
|
// Extend HTMLCanvasElement with useful methods from the underlying Canvas:
|
||||||
['toBuffer', 'pngStream', 'createPNGStream', 'jpgStream', 'createJPGStream']
|
var methods = ['toBuffer', 'pngStream', 'createPNGStream', 'jpegStream',
|
||||||
.forEach(function(key) {
|
'createJPEGStream'];
|
||||||
|
methods.forEach(function(key) {
|
||||||
HTMLCanvasElement.prototype[key] = function() {
|
HTMLCanvasElement.prototype[key] = function() {
|
||||||
var canvas = idlUtils.implForWrapper(this)._canvas;
|
var canvas = idlUtils.implForWrapper(this)._canvas;
|
||||||
return canvas[key].apply(canvas, arguments);
|
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'
|
Canvas: '#createCanvas'
|
||||||
});
|
});
|
||||||
|
@ -87,9 +87,12 @@ module.exports = function(paper) {
|
||||||
fps: 30,
|
fps: 30,
|
||||||
prefix: 'frame-',
|
prefix: 'frame-',
|
||||||
amount: 1,
|
amount: 1,
|
||||||
|
format: 'png' // Supported: 'png' or 'jpeg'
|
||||||
}, options);
|
}, options);
|
||||||
if (!options.directory)
|
if (!options.directory)
|
||||||
throw new Error('Missing 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,
|
var view = this,
|
||||||
count = 0,
|
count = 0,
|
||||||
frameDuration = 1 / options.fps,
|
frameDuration = 1 / options.fps,
|
||||||
|
@ -108,8 +111,9 @@ module.exports = function(paper) {
|
||||||
time: frameDuration * count,
|
time: frameDuration * count,
|
||||||
count: count
|
count: count
|
||||||
}));
|
}));
|
||||||
var file = path.join(options.directory, options.prefix +
|
var file = path.join(options.directory,
|
||||||
(paddedStr + count).slice(-padding) + '.png');
|
options.prefix + (paddedStr + count).slice(-padding)
|
||||||
|
+ '.' + options.format);
|
||||||
var out = view.exportImage(file, function() {
|
var out = view.exportImage(file, function() {
|
||||||
// Once the file has been closed, export the next fame:
|
// Once the file has been closed, export the next fame:
|
||||||
var then = Date.now();
|
var then = Date.now();
|
||||||
|
@ -140,8 +144,8 @@ module.exports = function(paper) {
|
||||||
exportImage: function(path, callback) {
|
exportImage: function(path, callback) {
|
||||||
this.update();
|
this.update();
|
||||||
var out = fs.createWriteStream(path),
|
var out = fs.createWriteStream(path),
|
||||||
stream = this._element.createPNGStream();
|
format = /\.jp(e?)g$/.test(path) ? 'jpeg' : 'png'
|
||||||
// Pipe the png stream to the write stream:
|
stream = this._element[format + 'Stream']();
|
||||||
stream.pipe(out);
|
stream.pipe(out);
|
||||||
if (callback) {
|
if (callback) {
|
||||||
out.on('close', callback);
|
out.on('close', callback);
|
||||||
|
|
2
dist/paper-core.js
vendored
2
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* 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.
|
* 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.
|
* 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.
|
* 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