/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://p5js.sketchpad.cc/sp/pad/view/ro.PB24ysTWPk1/rev.294
*
* authors:
* Kris Frajer
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
var circles = [];
var pen;
var resultx1 = [];
var resulty1 = [];
var resultx2 = [];
var resulty2 = [];
function setup() {
createCanvas(640, 640);
circles[0] = {
c: createVector(0, 0),
r: 150,
t: 0.01
};
for (var i = 0; i < 1; i++) {
circles.push(new Circle(circles[i].c, circles[i].r, circles[i].t));
};
pen = new Pen(circles[circles.length - 1].c, circles[circles.length - 1].r, circles[circles.length - 1].t);
}
function draw() {
background(255);
translate(width / 2, height / 2);
push();
stroke(0);
noFill();
ellipse(circles[0].c.x, circles[0].c.y, 2 * circles[0].r);
for (var i = 1; i < circles.length; i++) {
circles[i].update();
circles[i].show();
};
//pen.update();
pen.show();
pen.showPtList();
pop();
fill(0,0,250);
for(var pp=0;pp<resultx1.length;pp++){
ellipse(resultx1[pp]+resultx2[pp], resulty1[pp]+resulty2[pp], 5);
}
// stroke(255, 0, 0);
// noFill();
// beginShape();
// for (var j = 0; j < result.length; j += 2) {
// vertex(result[j], result[j + 1]);
// };
// endShape();
}
function Circle(c, r, t) {
this.r = r / 3;
this.c = createVector(r + this.r, c.y);
this.t = -2 * t;
this.show = function() {
translate(c.x, c.y);
stroke(0);
noFill();
ellipse(this.c.x, this.c.y, 2 * this.r);
};
this.update = function() {
resultx1.push(this.c.x);
resulty1.push(this.c.y);
this.c.rotate(this.t);
};
}
function Pen(c, r, t) {
this.c = createVector(r, c.y);
this.t = 4 * t;
//this.ptListx=[];
this.show = function() {
noStroke();
fill(255, 0, 0);
this.update();
translate(c.x, c.y);
ellipse(this.c.x, this.c.y, 5);
//this.ptListx.push(this.c.x);
};
this.showPtList=function(){
fill(0, 0, 255);
//for(var pp=0;pp<this.ptListx.length;pp++){
// ellipse(this.ptList[pp], this.ptList[pp], 5);
//}
}
this.update = function() {
resultx2.push(this.c.x);
resulty2.push(this.c.y);
this.c.rotate(this.t);
};
}