xxxxxxxxxx
75
let r1 = 100; let r2 = 50;
let angle = 0;
let rez = 10; let num = 1;
let play = false;
function setup() {
createCanvas(400, 400, WEBGL);
angleMode(DEGREES);
}
function draw() {
background(220);
rotateX(45);
noFill();
let i=0;
for(let theta=0; theta<360; theta+=10) {
// if (play) {
// beginShape();
// stroke(0);
// strokeWeight(1);
// for (let phi= i ; phi<= i + 360; phi+=rez) {
// let x = (r1 + r2*cos(phi + angle))*cos(theta);
// let y = (r1 + r2*cos(phi + angle))*sin(theta);
// let z = r2*sin(phi + angle);
// vertex(x, y, z);
// }
// endShape();
// }
for (let j=0; j<num; j++) {
let n = j*(360/num);
stroke(0);
beginShape();
strokeWeight(1);
for (let phi= i + n; phi< i + 30 + n; phi+=10) {
let x = (r1 + r2*cos(phi + angle))*cos(theta);
let y = (r1 + r2*cos(phi + angle))*sin(theta);
let z = r2*sin(phi + angle);
vertex(x, y, z);
}
endShape();
}
i+=10;
// beginShape(POINTS);
// strokeWeight(6);
// for (let phi= i + 90; phi< i + 91; phi++) {
// let x = (r1 + r2*cos(phi + angle))*cos(theta);
// let y = (r1 + r2*cos(phi + angle))*sin(theta);
// let z = r2*sin(phi + angle);
// vertex(x, y, z);
// }
// endShape();
}
angle += 1;
}
function keyPressed() {
if (keyCode == UP_ARROW) {
play = !play;
}
}