花火
夏を忘れないために花火です。Processing何かと役立つと思うので、ある程度使えるようにしてたい
float t; float g = -0.8; float v0 = 10.0; float h = 100.0; int divide = 30; float theta = 360/divide; float colors[][] = new float[divide+1][3]; int particlePerPiece = 5; float x0; float y0; void setup() { size(800,800); stroke(255); background(192,64,0); t=0; h=-300.0; x0=width/2; y0=height/2; smooth(); float r = random(0,255); float p = random(1,20); for (int i=0; i<=divide; i++) { colors[i][0] = r*p*i%255; colors[i][1] = r*p*i*i%255; colors[i][2] = r*p*i*i*i%255; } } void draw() { background(0,0,0); if (t<10.0){ ellipse(x0,y0-3*v0*t,10,30); } else { t-=10.0; for (int i=0; i<=divide; i++) { stroke(colors[i][0],colors[i][1],colors[i][2]); fill(colors[i][0],colors[i][1],colors[i][2]); ellipse(x0+v0*cos(radians(i*theta))*t, y0+h+sin(radians(i*theta))*v0*t-g*t*t, 4,4); /*if (t>5){ for (int j=0; j<particlePerPiece; j++) { ellipse(x0+v0*cos(radians(i*theta))*(t-0.1)+random(-5,5), y0+h+sin(radians(i*theta))*v0*(t-0.1)-g*(t-0.1)*(t-0.1)+random(-200,0)/2,2,2); } }*/ } t += 10.0; // uuuuuu } t+=0.1; if (t > 35) { stroke(255,255,255); fill(255,255,255); t = 0; } } void mousePressed(){ saveFrame("output.png"); }
正直ゴミコードです。