DISCREACCIÓN
Juan Carlos Lozano R.
INTERACTIVO
Posición y estados
int posx;
int posy;
color relleno;
int estado;
void setup()
{
size(500, 300);
background(0);
posx = width/2;
posy = height/2;
relleno = color(0);
estado = 0;
}
void draw()
{
if (estado == 0)
{
relleno = color(255,0,0);
posx++;
} else if (estado == 1)
{
relleno = color(255,255,255);
posy += 1;
} else if (estado == 2)
{
relleno = color(0,255,0);
posx--;
} else if (estado == 3)
{
relleno = color(0,0,255);
posy--;
}
stroke(relleno);
fill(relleno);
rect(posx, posy, 20, 20);
}
void keyPressed()
{
if( key == 'a' || keyCode == LEFT )
{
estado = 2;
}
else if(key == 's' || keyCode == DOWN )
{
estado = 1;
}
else if(key == 'd' || keyCode == RIGHT )
{
estado = 0;
}
else if(key == 'w' || keyCode == UP )
{
estado = 3;
}
}
Operar con d pad
â—„ â–² â–º â–¼
Dibujar mano alzada
void setup() {
size(500, 300);
background(0);
}
void draw() {
stroke(100);
//line(pmouseX, pmouseY, mouseX, mouseY);
stroke(random(255), random (255), random (255));
line(pmouseX, pmouseY, mouseX, mouseY);
}
void keyPressed (){
background (255);
}
Pintar imagen por pixel
PImage leon;
void setup()
{
size (500,300);
background (0);
leon= loadImage ("leon.jpg");
imageMode (CENTER);
}
void draw(){
leon.loadPixels();
int x= (int)random(leon.width);
int y= (int)random (leon.height);
int posicionPixel = x+(y*leon.width);
color elpixel= leon.pixels[posicionPixel];
noStroke();
fill (elpixel);
ellipse(x,y,5,5);
}
PShape sol;
void setup () {
size(400, 400);
background(252,214,2);
}
void draw () {
background(252,214,2);
stroke(0);
fill(0);
translate (width / 2, height / 2);
sol = createShape (RECT, 0, 0, 1, 1);
float zoom = map (mouseX, 0, 1, 0.1, 1);
scale (zoom);
shape (sol, -0.5,-0.5);
Composición dÃa noche
Descargar y ver en Processing 3..1
Llamado al texto
PImage bg;
int posx;
int velx;
void setup()
{
size (800,498);
bg = loadImage("surfin_sksy.jpg");
posx = 20;
velx = 4;
}
void draw ()
{
background(bg);
fill(0,0,0,155);
noStroke();
quad(0, height - 185, width, height - 185, width, height, 0, height);
PFont f = loadFont("Futura-CondensedExtraBold-48.vlw");
textFont(f,60);
fill(255,255,255,170);
text("Colombia",40, height - 90);
textFont(f, 40);
fill(255,255,255,170);
text("\" Lo estoy logrando\"",posx,height-40);
posx = posx + velx;
if (posx > height +360)
{
posx = -360;
}
}
Descargar y ver en Processing 3..1
int x;
int y;
void setup()
{
size (500,300);
background (250);
}
void draw(){
noStroke();
int x=0;
int y=0;
while (x<width && y< height)
{
fill (random (250),random(250),random(250));
rect (x,y,10,10);
x= x+10;
if (x>=width){
y=y+10;
x=0; } }
}