💾 Archived View for oppen.digital › memex › generative › moons captured on 2021-12-05 at 23:47:19. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
//Download Processing at https://processing.org ArrayList lines = new ArrayList<Line>(); PShape mappedShape; float minLength; float reduction; float fov = PI/3f; float cameraZ = (800/2f) / tan(fov/2f); boolean drawPlanetMass = true; void setup(){ size(800, 800, P3D); noCursor(); blendMode(ADD); hint(ENABLE_DEPTH_SORT); smooth(8); generate(); } void draw(){ lights(); background(0); if(drawPlanetMass) { noStroke(); fill(0, 20, 30); sphere(3950f); } perspective(fov, 1f, cameraZ/10f, 14500f); camera(-width/2f, -height/2f, 10250f, 0f, 0f, 0f, 0.0f, 1.0f, 0.0f); rotateY((TAU*frameCount)/3000); rotateY((TAU*mouseX)/width); rotateX((TAU*mouseY)/height); shape(mappedShape); } void mouseClicked() { generate(); } void keyPressed() { if (key == 'e') { }else if(key == 'm'){ drawPlanetMass = !drawPlanetMass; } } void generate(){ lines.clear(); minLength = random(0.2f, 1f); reduction = random(1.8f, 2f); Point origin = new Point(width/2, height/2); int dendrites = (int) random(1, 8); for(int i = 0 ; i < dendrites ; i++){ float angleRnd = random(-1f, 1f); float angle = TAU/dendrites * i; angle += TAU/dendrites; grow(origin, 85f, angle + angleRnd); } mappedShape = createShape(); mappedShape.beginShape(LINES); mappedShape.stroke(255, 40f); mappedShape.strokeWeight(0.75f); int r = 4000; int linesCount = lines.size(); for(int i = 0 ; i < linesCount ; i++){ Line line = (Line) lines.get(i); float x1 = r * (sin(line.a.y) * cos(line.a.x)); float y1 = r * (sin(line.a.y) * sin(line.a.x)); float z1 = r * cos(line.a.y); PVector start = new PVector(x1, y1, z1); float x2 = r * (sin(line.b.y) * cos(line.b.x)); float y2 = r * (sin(line.b.y) * sin(line.b.x)); float z2 = r * cos(line.b.y); PVector end = new PVector(x2, y2, z2); if(start.dist(end) < r/4) { mappedShape.vertex(x1, y1, z1); mappedShape.vertex(x2, y2, z2); } } mappedShape.endShape(); } void grow(Point origin, float length, float angle){ if(length < minLength){ return; } pushMatrix(); translate(origin.x, origin.y); rotate(angle); lines.add(new Line(screenX(0f, 0f), screenY(0f, 0f), screenX(length, 0f), screenY(length, 0f))); for(int i = 0 ; i < 4 ; i++){ grow(new Point(length / reduction, 0f), length / reduction, random(-6f, 6f)); } popMatrix(); } class Point{ float x; float y; Point(float x, float y){ this.x = x; this.y = y; } } class Line{ Point a; Point b; Line(float x1, float y1, float x2, float y2){ a = new Point(x1, y1); b = new Point(x2, y2); } }