Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,13 @@
void setup() {
size(500, 500, P3D);
}
void draw() {
background(192);
translate(width/2, height/2);
// optional color and lighting style
stroke(200);
fill(255);
lights();
// draw sphere
sphere(200);
}

View file

@ -0,0 +1,45 @@
float rotX, rotY;
PVector[][] sphere;
int detail = 50;
void setup() {
size(600, 600, P3D);
background(50, 50, 200);
fill(255, 0, 200);
stroke(0, 40);
sphere = new PVector[detail+1][detail+1];
}
void draw() {
pointLight(255, 255, 255, -width, -height, 2*height);
translate(width/2, height/2);
rotateX(rotX);
rotateY(rotY);
float r = 200;
for (int i = 0; i <= detail; i++) {
float rows = map(i, 0, detail, 0, PI);
for (int j = 0; j <= detail; j++) {
float columns = map(j, 0, detail, 0, TWO_PI);
float x = r * sin(rows) * cos(columns);
float y = r * sin(rows) * sin(columns);
float z = r * cos(rows);
sphere[i][j] = new PVector(x, y, z);
}
}
for (int i = 0; i < detail; i++) {
beginShape(TRIANGLE_STRIP);
for (int j = 0; j <= detail; j++) {
PVector v1 = sphere[i][j];
vertex(v1.x, v1.y, v1.z);
PVector v2 = sphere[i+1][j];
vertex(v2.x, v2.y, v2.z);
}
endShape();
}
}
void mouseDragged() {
rotY -= (mouseX - pmouseX) * 0.01;
rotX -= (mouseY - pmouseY) * 0.01;
}