xxxxxxxxxx
68
let font
let curIndex = 0;
// Create a capturerexports a WebM video
var capturer = new CCapture( { format: 'webm' } );
function preload() {
//font = loadFont('/EBGaramond-Regular.ttf');
echoesLines = loadStrings('asa.txt');
}
function setup() {
createCanvas(600, 600);
//textFont(font);
textSize(18);
//background(220);
//frameRate(20);
}
var startMillis;
function draw() {
if (frameCount === 1) {
capturer.start();
}
if (startMillis == null) {
startMillis = millis();
}
// duration in milliseconds
var duration = 10000;
// compute how far we are through the animation as a value between 0 and 1.
var elapsed = millis() - startMillis;
var t = map(elapsed, 0, duration, 0, 1);
// if we have passed t=1 then end the animation.
if (t > 1) {
noLoop();
console.log('finished recording.');
capturer.stop();
capturer.save();
return;
}
background(220);
for (let i = 0; i < echoesLines.length; i++){
text(echoesLines[i], 110, 150+i*5);
translate(p5.Vector.fromAngle(millis() / 1000, 5));
}
console.log('capturing frame');
capturer.capture(document.getElementById('defaultCanvas0'));
}
function mousePressed(){
//text(echoesLines[i])
//shuffle (echoesLines, true);
}
//textLeading((mouseX / width) *64);
//text(echoesLines, 100, 100, 200, 200);