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
...
final int PIXEL = 1; // done final int PIXEL_INVERT = 2; // done final int PIXEL_HFLIP = 3; // done final int PIXEL_VFLIP = 4; // done final int PIXEL_ROOTED = 5; final int PIXEL_SQUARED = 6; final int PIXEL_BRIGHTNESS = 7; final int PIXEL_RANDOM = 8; final int PIXEL_HDIST = 9; final int PIXEL_VDIST = 10; void main() { background(0); animate(draw); } int color(int rt, int gt, int bt) { int r = (rt>255?255:rt)<0?0:(rt>255?255:rt); int g = (gt>255?255:gt)<0?0:(gt>255?255:gt); int b = (bt>255?255:bt)<0?0:(bt>255?255:bt); return (255 * pow(2, 24)) + (r * pow(2, 16)) + (g * pow(2, 8)) + b; } int avgColor(int c1, int c2) { return color((red(c1)+red(c2))/2, (green(c1)+green(c2))/2, (blue(c1)+blue(c2))/2); } void applyFilter(int mode, int w, int h, int val) { int cw = 320/w; int ch = 320/h; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { int ax = (double)i*(double)cw + (double)cw/2.0; int ay = (double)j*(double)ch + (double)ch/2.0; if (mode == PIXEL_HFLIP) { ax = 319 - (i*cw + cw/2); } else if (mode == PIXEL_VFLIP) { ay = 319 - (j*ch + ch/2); } int c = getColor(ax, ay); if (mode == PIXEL_INVERT) { c = color(255-red(c), 255-green(c), 255-blue(c)); } fill(red(c), green(c), blue(c)); rect(i*cw - 1, j*ch - 1, cw+1, ch+1); } } } double t = 0; void draw() { background(0, 0, 0, 0.025); fill(255); noStroke(); //ellipse(160.0 + (cos((double)millis()/1000.0) * 80.0), 160.0 + (sin((double)millis()/1000.0) * 80.0), 120, 120); fill(255, 0, 0); ellipse(160.0 + (cos((double)t/30) * 80.0) + (cos((double)t/15) * 60.0), 160.0 + (sin((double)t/30) * 80.0) + (sin((double)t/15) * 60.0), 30, 30); applyFilter(PIXEL, 16, 16, 0); t += 3; }
Canvas not supported.
Programado por
segfaultdev
0 votos
170 descargas
38 usos