Ciao 访客, welcome back to old school! :p
int num = 500;Star stars[] = new Star[num];void setup() { size(800, 600, P3D); for (int i=0; i< num; i++) { stars[i] = new Star(); } frameRate(25);}void draw() { background(0); for (int i=0; i< num; i++) { stars[i].display(); }}class Star { float x = random(width); float y = random(height); float z = random(600); int a = 0; float d = 5; void display() { fill(255, a); pushMatrix(); translate(x, y, z-100); box(d); popMatrix(); z+=random(10.0, 25.0); //change alpha with z position a+=z/20; if (z>600) { z=0; a=0; x = random(width); y = random(height); } }}
int num = 4500; Star stars[] = new Star[num]; void setup() { size(800, 600, P3D); smooth(); for (int i=0; i< num; i++) { stars[i] = new Star(); } frameRate(25);} void draw() { background(0); for (int i=0; i< num; i++) { stars[i].display(); }} class Star { float x = random(width); float y = random(height); float z = random(600); int a = 0; void display() { pushMatrix(); translate(0, 0, z-100); stroke(0); box(0); stroke(255, a); line(x, y, z, x, y, z+45); popMatrix(); z+=random(10.0, 25.0); //change alpha with z position a+=z/20; if (z>600) { z=0; a=0; x = random(width); y = random(height); } }}
import processing.opengl.*;int num = 4500; Star stars[] = new Star[num]; void setup() { size(800, 600, OPENGL); smooth(); for (int i=0; i< num; i++) { stars[i] = new Star(); } frameRate(25);} void draw() { background(0); for (int i=0; i< num; i++) { stars[i].display(); }} class Star { float x = random(width); float y = random(height); float z = random(600); int a = 0; void display() { stroke(255, a); line(x, y, z, x, y, z+45); z+=random(10.0, 25.0); //change alpha with z position a+=z/20; if (z>600) { z=0; a=0; x = random(width); y = random(height); } }}