Render Css3 Animation As A Sequence Of Image Files With Phantomjs
I didn't work with PhantomJS before, but want to use it to render some custom-made CSS3 animated sequences to sets of PNG files on server side to join them into a single video file
Solution 1:
You could have phantomjs take a snapshot every few hundred milliseconds and base your css3 animations around that.
An example script (snap.js) for this would be:
var system = require('system');
var page = newWebPage();
var address = system.args[1];
var wait = parseInt(system.args[2]);
var iterations = parseInt(system.args[3]);
page.open(address, function(){
(functionsnap(i){
if(i < iterations){
window.setTimeout(function(){
page.render('capture/'+i+'.png');
snap(++i);
}, wait);
}
else{
phantom.exit();
}
})(0);
});
You would use phantomjs to call the script like this:
./phantomjs snap.js http://google.com 500 5
and it would take a snapshot of the google homepage every half a second, 5 times.
Then if you paused your animation every half a second phantomjs would capture those points.
Post a Comment for "Render Css3 Animation As A Sequence Of Image Files With Phantomjs"