xxxxxxxxxx
let phi;
let oct;
let isoc;
let dodec;
let tetr;
let hexa;
let a;
let b;
let c;
let d;
let e;
let f;
let g;
function setup(){
phi = (1+(sqrt(5)))/2; //golden ratio 5
oct = 94;//94 size et al
isoc = 100;//100
dodec = 69;//69
tetr = 100;//190
hexa = 276;//476
//octahedron
a = (1/(2*sqrt(2)))*oct;
b = (1/2)*oct;
//isocahedron
c = ((1/2))*isoc;
d = (1/(2*phi))*isoc;
//dodecahedron
e = (1/phi)*dodec;
f = (2-phi)*dodec;
//tetrahedron
// fill(155,40); - I added
g = (1)*tetr; // change g to f to change the dodec into a weird new shape
//hexahedron
//use box function
createCanvas(800,600,WEBGL);
noFill();
colorMode(HSB, 210);//205
}
function draw(){
background(15); // 200, shade of gray. Comment out for psychadelics.
// stroke(0); 0 does nothing
// translate(width/2,height/2,0); w=2 num is size, h=2 does nothing,0 does nothing.
camera(mouseX-width/1.1, mouseY-height/1.5, 500.0, // eyeX, eyeY, eyeZ
0.0, 0.0, 0.0, // centerX, centerY, centerZ // 0 0 0
0.0, 1.0, 0.0); // 0 1 0
//octahedron with a/b
stroke(0,90,0); //51,255,255=opacity?
fill(155,40);
push();
translate(0,0,0);// I added to see octa alone while I adjust colors etc.
rotateX(radians(125)); //25
beginShape();
vertex(-a,0,a);//-a,0,a
vertex(-a,0,-a);
vertex(0,b,0);
endShape(CLOSE);
beginShape();
vertex(-a,0,-a);
vertex(a,0,-a);
vertex(0,b,0);
endShape(CLOSE);
beginShape();
vertex(a,0,-a);
vertex(a,0,a);
vertex(0,b,0);
endShape(CLOSE);
beginShape();
vertex(a,0,a);
vertex(-a,0,a);
vertex(0,b,0);
endShape(CLOSE);
beginShape();
vertex(a,0,-a);
vertex(a,0,a);
vertex(0,-b,0);
endShape(CLOSE);
beginShape();
vertex(a,0,a);
vertex(-a,0,a);
vertex(0,-b,0);
endShape(CLOSE);
beginShape();
vertex(-a,0,a);
vertex(-a,0,-a);
vertex(0,-b,0);
endShape(CLOSE);
beginShape();
vertex(-a,0,-a);
vertex(a,0,-a);
vertex(0,-b,0);
endShape(CLOSE);
pop();
//isocahedron with d/c
stroke(102,255,255);
beginShape();
vertex(0,d,-c);
vertex(d,c,0);
vertex(-d,c,0);
endShape(CLOSE);
beginShape();
vertex(0,d,c);
vertex(-d,c,0);
vertex(d,c,0);
endShape(CLOSE);
beginShape();
vertex(0,d,c);
vertex(0,-d,c);
vertex(-c,0,d);
endShape(CLOSE);
beginShape();
vertex(0,d,c);
vertex(c,0,d);
vertex(0,-d,c);
endShape(CLOSE);
beginShape();
vertex(0,d,-c);
vertex(0,-d,-c);
vertex(c,0,-d);
endShape(CLOSE);
beginShape();
vertex(0,d,-c);
vertex(-c,0,-d);
vertex(0,-d,-c);
endShape(CLOSE);
beginShape();
vertex(0,-d,c);
vertex(d,-c,0);
vertex(-d,-c,0);
endShape(CLOSE);
beginShape();
vertex(0,-d,-c);
vertex(-d,-c,0);
vertex(d,-c,0);
endShape(CLOSE);
beginShape();
vertex(-d,c,0);
vertex(-c,0,d);
vertex(-c,0,-d);
endShape(CLOSE);
beginShape();
vertex(-d,-c,0);
vertex(-c,0,-d);
vertex(-c,0,d);
endShape(CLOSE);
beginShape();
vertex(d,c,0);
vertex(c,0,-d);
vertex(c,0,d);
endShape(CLOSE);
beginShape();
vertex(d,-c,0);
vertex(c,0,d);
vertex(c,0,-d);
endShape(CLOSE);
beginShape();
vertex(0,d,c);
vertex(-c,0,d);
vertex(-d,c,0);
endShape(CLOSE);
beginShape();
vertex(0,d,c);
vertex(d,c,0);
vertex(c,0,d);
endShape(CLOSE);
beginShape();
vertex(0,d,-c);
vertex(-d,c,0);
vertex(-c,0,-d);
endShape(CLOSE);
beginShape();
vertex(0,d,-c);
vertex(c,0,-d);
vertex(d,c,0);
endShape(CLOSE);
beginShape();
vertex(0,-d,-c);
vertex(-c,0,-d);
vertex(-d,-c,0);
endShape(CLOSE);
beginShape();
vertex(0,-d,-c);
vertex(d,-c,0);
vertex(c,0,-d);
endShape(CLOSE);
beginShape();
vertex(0,-d,c);
vertex(-d,-c,0);
vertex(-c,0,d);
endShape(CLOSE);
beginShape();
vertex(0,-d,c);
vertex(c,0,d);
vertex(d,-c,0);
endShape(CLOSE);
//dodecahedron with e/f
stroke(153,255,255);
translate(100,0,0);//coords 0,34,0
beginShape();
vertex(f,0,dodec);
vertex(-f,0,dodec);
vertex(-e,e,e);
vertex(0,dodec,f);
vertex(e,e,e);
endShape(CLOSE);
beginShape();
vertex(-f,0,dodec);
vertex(f,0,dodec);
vertex(e,-e,e);
vertex(0,-dodec,f);
vertex(-e,-e,e);
endShape(CLOSE);
beginShape();
vertex(f,0,-dodec);
vertex(-f,0,-dodec);
vertex(-e,-e,-e);
vertex(0,-dodec,-f);
vertex(e,-e,-e);
endShape(CLOSE);
beginShape();
vertex(-f,0,-dodec);
vertex(f,0,-dodec);
vertex(e,e,-e);
vertex(0,dodec,-f);
vertex(-e,e,-e);
endShape(CLOSE);
beginShape();
vertex(0,dodec,-f);
vertex(0,dodec,f);
vertex(e,e,e);
vertex(dodec,f,0);
vertex(e,e,-e);
endShape(CLOSE);
beginShape();
vertex(0,dodec,f);
vertex(0,dodec,-f);
vertex(-e,e,-e);
vertex(-dodec,f,0);
vertex(-e,e,e);
endShape();
beginShape();
vertex(0,-dodec,-f);
vertex(0,-dodec,f);
vertex(-e,-e,e);
vertex(-dodec,-f,0);
vertex(-e,-e,-e);
endShape(CLOSE);
beginShape();
vertex(0,-dodec,f);
vertex(0,-dodec,-f);
vertex(e,-e,-e);
vertex(dodec,-f,0);
vertex(e,-e,e);
endShape(CLOSE);
beginShape();
vertex(dodec,f,0);
vertex(dodec,-f,0);
vertex(e,-e,e);
vertex(f,0,dodec);
vertex(e,e,e);
endShape(CLOSE);
beginShape();
vertex(dodec,-f,0);
vertex(dodec,f,0);
vertex(e,e,-e);
vertex(f,0,-dodec);
vertex(e,-e,-e);
endShape(CLOSE);
beginShape();
vertex(-dodec,f,0);
vertex(-dodec,-f,0);
vertex(-e,-e,-e);
vertex(-f,0,-dodec);
vertex(-e,e,-e);
endShape(CLOSE);
beginShape();
vertex(-dodec,-f,0);
vertex(-dodec,f,0);
vertex(-e,e,e);
vertex(-f,0,dodec);
vertex(-e,-e,e);
endShape(CLOSE);
//tetrahedron
stroke(204,255,255);
push();
translate(0,0,0);//0,34,0
rotateZ(10);
rotateX(15);
beginShape();
vertex(g,g,g);
vertex(-g,g,-g);
vertex(g,-g,-g);
endShape(CLOSE);
beginShape();
vertex(-g,g,-g);
vertex(-g,-g,g);
vertex(g,-g,-g);
endShape(CLOSE);
beginShape();
vertex(g,g,g);
vertex(g,-g,-g);
vertex(-g,-g,g);
endShape(CLOSE);
beginShape();
vertex(g,g,g);
vertex(-g,-g,g);
vertex(-g,g,-g);
endShape(CLOSE);
pop();
//hexahedron
stroke(155,255,255);
push();
translate(-25,13,20); //-25 bigger is right,13 bigger is down,0 bigger is closer, Y is opposite, not like Acad!
box(hexa);
pop();
}