Toggle navigation
Explora
(current)
Aprende
Crea
Retos
×
Aspectos básicos
void main() {...}
for ( int i = 0 ; i < N ; i++ ) {...}
while (condición) {...}
do {...} while (condición);
if (condición) {...}
if (condición) {...} else {...}
switch (valor) {...}
Mostrar y pedir datos
print()
println()
readInteger()
readDouble()
readChar()
readString()
Funciones matemáticas
abs(n)
log(n)
sqrt(n)
pow(b,e)
floor(n)
ceil(n)
round(n)
sin(n)
cos(n)
tan(n)
asin(n)
acos(n)
atan(n)
random(n)
Funciones gráficas
point(x,y)
line(x1,y1,x2,y2)
ellipse(x,y,w,h)
rect(x,y,w,h)
triangle(x1,y1,x2,y2,x3,y3)
text(msg,x,y)
textWidth(msg)
textSize(n)
background(r,g,b,a)
strokeWeight(n)
stroke(r,g,b,a)
noStroke()
fill(r,g,b,a)
noFill()
image(url, x,y,w,h)
Nuevo
Ayuda
Probar
...
int pn = 10; int art = 120; int points[] = new int[pn]; int corx[] = new int[pn]; int r[] = new int[pn]; int g[] = new int[pn]; int b[] = new int[pn]; int max[] = new int[pn]; class Particle { double x = 0; double y = 0; double dirx = 0; double diry = 0; double life = 0; double r = 0; double g = 0; double b = 0; Particle() {} } Particle[] particles = new Particle[pn*art]; void main() { for (int i = 0; i < pn; i++) { points[i] = random(320, 480); corx[i] = random(320); r[i] = (round(random(1))*255)+63; g[i] = (round(random(1))*255)+63; b[i] = (round(random(1))*255)+63; max[i] = round(random(20, 100)); } for (int i = 0; i < pn*art; i++) { particles[i] = new Particle(); } background(0); animate(draw); } void draw() { background(0, 0, 0, 0.1); strokeWeight(6); for (int i = 0; i < pn; i++) { stroke(r[i], g[i], b[i]); point(corx[i], points[i]); points[i] -= points[i]<=320?((points[i]-(max[i]/3))/12):2.4; if (points[i] <= max[i]) { int rnd = round(random(0, 4)); for (int j = art*i; j < art*(i+1); j++) { particles[j].r = r[i]; particles[j].g = g[i]; particles[j].b = b[i]; particles[j].life = 100; particles[j].x = corx[i]; particles[j].y = points[i]; particles[j].dirx = random(-4, 4); int rs = round(random(-0.5, 2.5)); if (rnd == 0) particles[j].diry = random(0, -4); // Shape 1 else if (rnd == 1) particles[j].diry = random(0, (-abs(cos(particles[j].dirx+PI)*4))); // Shape 2 else if (rnd == 2) { particles[j].diry = random(0, cos(particles[j].dirx+PI)*3);particles[j].dirx = random(0, sin(particles[j].diry+PI)*3); } else if (rnd == 3) { particles[j].diry = sin(j)*3+random(-0.2,1);particles[j].dirx = cos(j)*3+random(-0.2,0.2); } else if (rnd == 4) particles[j].diry = cos(particles[j].dirx+PI)*2; // //particles[j].diry = 1; // Shape 3 //particles[j].diry = cos(particles[j].dirx+PI)*2; // // //particles[j].diry = 0; } points[i] = random(400, 480); corx[i] = random(320); r[i] = (round(random(1))*255)+63; g[i] = (round(random(1))*255)+63; b[i] = (round(random(1))*255)+63; max[i] = round(random(20, 100)); } } for (int i = 0; i < pn*art; i++) { if (particles[i].life > 0) { stroke(particles[i].r, particles[i].g, particles[i].b, particles[i].life/100); strokeWeight(2); point(particles[i].x, particles[i].y); particles[i].x += particles[i].dirx; particles[i].y += particles[i].diry; particles[i].dirx *= 0.96; particles[i].diry += 0.2; particles[i].life -= 3; } } }
Canvas not supported.
Programado por
segfaultdev
4 votos
394 descargas
71 usos