Pulsa la tecla 'a' para dibujar círculos aleatorios cercanos, 'b' para dibujarlos secuancialmente en horizontal, y 'r' para limpiar la pantalla.
La elección del color también es aleatoria
“dibujo secuencial y aleatorio” by Francisco Montero Arranz
https://openprocessing.org/sketch/291425
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
CC Attribution ShareAlike
dibujo secuencial y aleatorio
Montero Arranz
xxxxxxxxxx
int estado; // casos '0', '1' o '2', al pulsar las teclas 'a' o 'b' o 'r'
int sep; //separaci�³n entre c�•rculos caso 'a'
int diameter; //tama�±o c�•rculo dibujado
int x; // coordenada de avance horizontal
int y; // coordenada de avance vertical
int vx; // incremento avance pelota en 'x' caso 'b'
int t; //grado de transparencia del lienzo para hacer la estela de los c�•rculos
float a, b, c; //valor aleatorio del color
void setup() {
size(500, 500); //tama�±o del lienzo
//inicio variables.
diameter=35;
sep =25;
x=0;
y=0;
vx=3; //tomar valores entre 5 y 30
t=10; // tomar valores entre 0 y 15
estado=1;// pulsar las teclas 'a' o 'b' para cambiar la ejecuci�³n del programa
background(0); //fondo blanco
}
void draw() {
fill(255);
textSize(15);
text("Pulsa las teclas 'a' o 'b' para elegir el modo de dibujo aleatorio", 10, 10, 350, 50);
text("Pulsa ' r ' para limpiar pantalla", 10, 475);
switch(estado) { //tres casos, PULSANDO teclas 'a', 'b' o 'r' (limpia pantalla)
case 0: // tecla 'a'
a= random(255);
b= random(255);
c= random(255);
x += random(-sep, sep);
y += random(-sep, sep);
strokeWeight(2);
stroke(a, b, c, 100);
fill(x, y, c, 100);
ellipse(x, y, diameter, diameter);
if (x>width || y>height || x<0 || y<0) {
x = width/2;
y = height/2;
}
break; //cada caso acaba siempre con un 'break'
case 1: // tecla 'b', caso por defecto
pelota();
break;
case 2: // tecla 'r', limpia pantalla
background(0);
text("Pulsa las teclas 'a' o 'b' para elegir el modo de dibujo aleatorio", 10, 10, 350, 50);
text("Pulsa ' r ' para limpiar pantalla", 10, 475);
//fill(255);
break;
}
}
void pelota() {
fill(0, 0, 0, t); //relleno negro y transparencia del t%
rect(0, 0, width, height); // dibuja en cada paso un rect�¡ngulo del tama�±o del lienzo,
// que ofrece el efecto de sombra
for (int i=1; i<8; i=i+1) {
noStroke();
fill(100, x, 0);
//fill(0, 255, 0);
ellipse(x, 50*i, diameter, diameter);
//fill(random(255)*i, random(255)*i, random(255)*i);
//ellipse(x, 50*i, 30, 30);
//fill(x, 255/i,random(255));
//ellipse(x, 50*i*random(10), diameter, diameter);
}
x=x+vx; //incremento avance en 'x'
if (x>=width || x<=0) { //cambio de sentido al llegar a los extremos hor'izontales.
vx=vx*-1; // 'rebote
}
}
void keyReleased() { //comprobaci�³n de si la tecla pulsada es 'a' o 'b' para decidir qu�© dibujo hacer
if (key=='a') {
estado=0;
}
if (key=='b') {
estado=1;
}
if (key=='r') {
estado=2;
}
}
See More Shortcuts