-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
271 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
define(function(require) { | ||
var p5 = require('p5'); | ||
require('p5.svg'); | ||
var assert = require('chai').assert; | ||
|
||
describe('IO/saveFrames', function() { | ||
it('should capture canvas frames', function(done) { | ||
new p5(function(p) { | ||
p.setup = function() { | ||
p.createCanvas(100, 100); | ||
p.strokeWeight(3); | ||
p.saveFrames('hello', 'png', 0.5, 10, function(frames) { | ||
try { | ||
assert.ok(frames.length > 1); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} finally { | ||
p.noCanvas(); | ||
} | ||
}); | ||
}; | ||
p.draw = function() { | ||
var i = p.frameCount * 2; | ||
p.line(0, 0, i, i); | ||
}; | ||
}); | ||
}); | ||
|
||
it('should capture svg frames', function(done) { | ||
new p5(function(p) { | ||
p.setup = function() { | ||
p.createSVG(100, 100); | ||
p.strokeWeight(3); | ||
p.saveFrames('hello', 'svg', 0.5, 10, function(frames) { | ||
try { | ||
assert.ok(frames.length > 1); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
p.noSVG(); | ||
}); | ||
}; | ||
p.draw = function() { | ||
var i = p.frameCount * 2; | ||
p.line(0, 0, i, i); | ||
}; | ||
}); | ||
}); | ||
|
||
it('should capture svg frames even omitting duration and fps', function(done) { | ||
this.timeout(0); | ||
new p5(function(p) { | ||
p.setup = function() { | ||
p.createSVG(100, 100); | ||
p.strokeWeight(3); | ||
p.saveFrames('hello', 'svg', null, null, function(frames) { | ||
try { | ||
assert.ok(frames.length > 1); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
p.noSVG(); | ||
}); | ||
}; | ||
p.draw = function() { | ||
var i = p.frameCount * 2; | ||
p.line(0, 0, i, i); | ||
}; | ||
}); | ||
}); | ||
|
||
it('should download svg frames', function(done) { | ||
new p5(function(p) { | ||
p.setup = function() { | ||
p.createSVG(100, 100); | ||
var _downloadFile = p.downloadFile; | ||
var count = 0; | ||
p.downloadFile = function() { | ||
count++; | ||
if (count > 1) { | ||
done(); | ||
p.noSVG(); | ||
} | ||
}; | ||
p.saveFrames('hello', 'svg', 0.5, 10); | ||
}; | ||
p.draw = function() { | ||
var i = p.frameCount * 2; | ||
p.line(0, 0, i, i); | ||
}; | ||
}); | ||
}); | ||
|
||
it('should wait all pending jobs done', function(done) { | ||
new p5(function(p) { | ||
p.setup = function() { | ||
p.createSVG(100, 100); | ||
var _downloadFile = p.downloadFile; | ||
var pending = 0; | ||
var _makeSVGFrame = p._makeSVGFrame; | ||
p._makeSVGFrame = function(options) { | ||
// slow version | ||
pending++; | ||
setTimeout(function() { | ||
_makeSVGFrame.call(p, options); | ||
}, 500); | ||
}; | ||
p.downloadFile = function() { | ||
pending--; | ||
if (pending === 0) { | ||
done(); | ||
p.noSVG(); | ||
} | ||
}; | ||
p.saveFrames('hello', 'svg', 0.5, 10); | ||
}; | ||
p.draw = function() { | ||
var i = p.frameCount * 2; | ||
p.line(0, 0, i, i); | ||
}; | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.