xxxxxxxxxx
47
var dots = [];
var maxdots = 12;
var startRadius = 0;
var endRadius = 60;
function setup() {
createCanvas(200, 200);
trigger.x = width/2;
trigger.y = height/2;
let angleinc = radians(360/maxdots);
let angle = 0;
for(let idx = 0; idx < maxdots; idx++) {
dot = {
'startx' : trigger.x + startRadius*Math.sin(angle),
'starty' : trigger.y + startRadius*Math.cos(angle),
'endx' : trigger.x + endRadius*Math.sin(angle),
'endy' : trigger.y + endRadius*Math.cos(angle),
};
dots.push( dot );
angle += angleinc;
}
}
function draw() {
background(0);
trigger_update(trigger);
if (trigger.animating) {
// calculate the time factor of our animation
let t = (millis() - trigger.animStarted) / trigger.animDuration;
// calculate the easing value for the given time factor
let pcent = EasingFunctions.easeInOutCubic(t);
fill(255, 255, 0);
for(dot of dots) {
console.log("processing dot");
let xpos = map(pcent, 0, 1, dot.startx, dot.endx);
let ypos = map(pcent, 0, 1, dot.starty, dot.endy);
ellipse(xpos, ypos, 15, 15);
}
}
trigger_draw(trigger);
}