/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.t6Vvemjih6Z/rev.945
*
* authors:
* Babele Dunnit
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// Pressing Control-R will render this sketch.
int i = 0;
void setup() { // this is run once.
// set the background color
background(255);
// specify canvas size
size(800, 800);
// smooth edges
smooth();
// limit the number of frames per second
frameRate(50);
// set the width of the line.
strokeWeight(20);
ellipse( width / 2, height/ 2, 20, 20 );
}
bool hasDivisor(int n)
{
for(int i = 2; i < sqrt(n); i++)
if(n % i == 0)
return true;
return false;
}
circlelen = 6;
multsix = 1;
float deltatheta = TWO_PI / 6.0;
float theta = 0.0;
void draw() { // this is run repeatedly.
if(i > 2000)
return;
if(i == circlelen)
{
multsix++;
circlelen += (6 * multsix);
deltatheta /= 2.0;
}
// set the color
// stroke(random(50), random(255), random(255), 100);
// ogni volta che entro disegno un dot
centerx = width / 2;
centery = height / 2;
// theta += /*i * */ TWO_PI / (6.0 * multsix);
theta = i * TWO_PI / (6.0 * multsix);
rho = 35 * multsix;
// trasformazza polazza-cartesiazza
x = rho * cos(theta) + centerx;
y = rho * sin(theta) + centery;
if(hasDivisor(i))
stroke(0, 255, 0, 100);
else
stroke(255, 0, 0, 100);
//line(x, y, x, y);
ellipse(x,y,15,15);
text(str(i), x, y);
print(x);
i++;
}