CITOPLASMA/PROCESSING
Guia practica para recordar y/o utilizar processing

CITOPLASMA 007 / V.4.0 / processing
citoplasma.com.mx

regresar

INTRODUCCIÓN:
Referencia teorica y práctica de processing.

 

//EJEMPLO001.CITOPLASMA.COM.MX.13.04.08
int x = 0;
int y = 55;

void setup() {
size (200,200);
}

void draw() {
background (x,0,0);
stroke (255,255,0);
line (x, y, x+20, y-40);
x = x + 1;
y = y + 2;
if (x > 200){
x = -55;
}
if (y > 200){
y = 0;
}
}

 

//EJEMPLO002.CITOPLASMA.COM.MX.13.04.08
void setup() {
size (200,200);
background (254,0,0);
stroke (254,254,0);
//noLoop();
}

void draw() {
diagonales (100,100);
diagonales (60,62);
diagonales (20,40);
}
// aqui se declara la función "diagonales" con las variables "x" y "y".
void diagonales(int x, int y) {
line(x, y, x+20, y-40);
line(x+20, y-40, x+50, y-40);
line(x+50, y-40, x+40, y);
line(x+40, y, x-30, y-20);
}

 

//EJERCICIO003.CITOPLASMA.COM.MX.13.04.08
int x = 10;

void setup() {
size (200,200);
}

void draw() {
background (255,0,0);
stroke (x,x,0);
point (x,105);
strokeWeight (x);
x = x + 1;
if (x > 200) {
x = 0;
}
}

 

//EJERCICIO004.CITOPLASMA.COM.MX.13.04.08
int variable = 0;

void setup () {
size (200,200);
}

void draw () {
background (variable,variable,0);
stroke (255,0,variable, 40);
strokeWeight (variable);
fill (255,variable,0, 60);
line (variable, 10, variable, 50);
bezier (variable, variable + 10, variable + 20, variable + 30, variable + 40, variable + 50, variable + 60, variable + 70);
point (variable, 60);
triangle (variable, 70, variable + 10, 70, variable + 5, 75);
noStroke ();
rect (variable + 20, 30, 20, 30);
noFill();
stroke (120,0,variable-10, 40);
ellipse (variable + 20, 120, 40, 40);
variable = variable + 1;
if (variable > 200) {
variable = 0;
}
}

 

//EJERCICIO005.CITOPLASMA.COM.MX.13.04.08
// Este ejercicio es para conocer strokeWeight(), strokeJoin() y strokeCap()
int posicion = 0;

void setup () {
size (200,200);
background (240,230,40);
//noLoop ();
}

void draw () {
noSmooth();
stroke (posicion + 5, 0, 0, 40);
strokeWeight (2);
line (posicion, 10, posicion + 40, 10);
strokeWeight (5);
line (posicion, 20, posicion + 40, 20);
strokeWeight (8);
strokeCap (ROUND);
line (posicion, 40, posicion + 40, 40);
strokeCap (SQUARE);
line (posicion, 50, posicion + 40, 50);
strokeCap (PROJECT);
line (posicion, 60, posicion + 40, 60);
fill (posicion/2, posicion, posicion/4, 30);
strokeWeight (5);
strokeJoin (BEVEL);
rect (posicion, 70, 10, 10);
strokeJoin (MITER);
rect (posicion, 100, 10, 10);
strokeJoin (ROUND);
rect (posicion, 120, 10, 10);

posicion = posicion + 1;
if (posicion > 200) {
posicion = 0;
}
}

 

//EJERCICIO006.CITOPLASMA.COM.MX.13.04.08
int variable = 100;

void setup() {
size (200,200);
noLoop();
}

void draw() {
background (255);

smooth();
stroke(255,0,0);
strokeWeight(5);
point (100,100);
stroke(255,0,0,20);
rect (0,0,200,200);

noStroke();
ellipseMode(RADIUS);
fill(255,0,0,30);
ellipse(variable, 33, 60, 60);//circulo rojo
fill(0,255,0,30);
ellipseMode(CORNER);
ellipse(variable, 33, 60, 60);//circulo verde
fill(0,0,255,30);
ellipseMode(CORNERS);
ellipse(variable, 33, 60, 60);//circulo azul

rectMode(CORNER);
fill(255,0,0,30);
rect(variable, 40, 60, 60);//rectangulo rojo
rectMode(CENTER);
fill(0,255,0,30);
rect(variable, 40, 60, 60);//rectangulo verde
rectMode(CORNERS);
fill(0,0,255,30);
rect(variable, 40, 60, 60);//rectangulo azul

variable = variable + 1;
if (variable > 200) {
variable = 0;
}
}

 

//EJERCICIO007.CITOPLASMA.COM.MX.14.04.08
int a = 100;
int b = 100;
int c = 50;
float posicion = 1;

void setup(){
size (200,200);
background (255);
}

void draw() {
fill (a,255,0,20);
noStroke ();
ellipse (a,b,c,c);
a++;
if (a > 255) {
a = 0;
}
stroke (255,0,0,10);
line (posicion,0,posicion*1.001,200);
posicion++;
if (posicion > 200) {
posicion = 0;
}
stroke (0,255,0,10);
line (posicion-20,0,(posicion*1.1)-10,200);
posicion++;
if (posicion > 200) {
posicion = 0;
}
}

 

//EJERCICIO008.CITOPLASMA.COM.MX.14.04.08
float x = 0;
float y = 0;
float x2 = 0;
float y2 = 0;

void setup(){
size(200,200);
stroke(255,255,0);
strokeWeight(3);
background(240,0,0);
}

void draw(){
//background(240,0,0);
point (x,y);
x=x+1;
//print (x + ", ");
y=y+0.626;
if (x > 200){
x=0;
}
if (y > 200){
y=0;
}
point (x2,y2);
x2=x2+0.626;
print (x2 + ", ");
y2=y2+1;
if (x2 > 200){
x2=0;
}
if (y2 > 200){
y2=0;
}
}

 

//EJERCICIO009.CITOPLASMA.COM.MX.14.04.08
float x = 0;
float y = 0;
int variablecolor1 = 30;
int variablecolor2 = 60;

void setup(){
//background(0,160,200);
size (200,200);
strokeWeight(5);
smooth();
rectMode(CENTER);
noStroke();
fill(0,255,255,10);
rect(100,100,0,50);
}

void draw(){
//background(0,160,200);
stroke(variablecolor1,variablecolor2,0);
point(x,y);
x = x+(1.1416);
y++;
if (x > 200){
x = 0;
}
if (y > 200){
y = 0;
}
if ((x > 50) && (y > 50) && (x < 150) && (y < 150)){
variablecolor1 = 10;
variablecolor2 = 10;
} else {
variablecolor1 = 255;
variablecolor2 = 255;
}
}

 

//EJEMPLO010.CITOPLASMA.COM.MX.15.04.08
int x = 0;
int colorfondo = 0;

void setup(){
size(200,200);
noFill();
stroke (255,255,0,70);
}

void draw(){
background(colorfondo,100,150);
x++;
colorfondo++;
if (x > 230){
x = -230;
}
if (colorfondo > 255){
colorfondo = 0;
//print (colorfondo + ", ");
}
for (int i = 5; i < 280; i = i + 3){
ellipse (x,100,i,i);
}

}

 

//EJERCICIO011.CITOPLASMA.COM.MX.15.04.08
size (200,200);
background(255,255,0);
stroke(255,0,0,10);
smooth();
for (int a = 5; a < 200; a += 5){
strokeWeight(a/4);
point (a, 5);
point (a, a);
strokeWeight(2);
line (a, 10, a, 190);
}

  //EJERCICIO012.CITOPLASMA.COM.MX.15.04.08
size(200,200);
background(0,100,200);
for (int i=0; i<200; i+=5){
for (int e=0; e<200; e+=5){
stroke(255,255,0,60);
strokeWeight(3);
smooth();
point (i,e);
}
}
 

//EJERCICIO013.CITOPLASMA.COM.MX.15.04.08
void setup (){
size(200,200);
background(0,100,50);
}

void draw(){
background(0,200,50);
for (int y=5; y<200; y+=5){
for (int x=5; x<y; x+=5){
stroke(255,0,0,50);
strokeWeight(3);
smooth();
point(x,y);
}
}

for (int y2=7; y2<200; y2+=5){
for (int x2=7; x2<y2; x2+=5){
stroke(255,255,0,80);
strokeWeight(3);
smooth();
point(x2,y2);
}
}

}

 

//EJERCICIO014.CITOPLASMA.COM.MX.29.09.08
void setup (){
size (200,200);
}

void draw () {
background (255);
smooth ();
stroke (255,0,0);
strokeWeight (2);
ellipseMode (CENTER);
ellipse (mouseX,mouseY,20,20);

bezier (10, 10, mouseX, mouseY, mouseX, mouseY, 195, 10);
bezier (10, 10, mouseX, mouseY, mouseX, mouseY, 10 , 195);
bezier (10, 195, mouseX, mouseY, mouseX, mouseY, 195, 195);
bezier (195, 195, mouseX, mouseY, mouseX, mouseY, 195, 10);
}

  //CITOPLASMA.COM.MX.EJERCICIO015.011008
size (200,200);
background (255,255,0);
stroke (255,0,0);
fill (0,0,255);
beginShape ();
for (int y = 0; y <= 200; y += 3){
for (int x = 0; x <= 200; x += 3){
vertex(x,y);
}
}
endShape();
 

//CITOPLASMA.COM.MX.EJERCICIO016.011008
void setup(){
size (200,200);
}

void draw(){
background (0,0,255);
stroke (255,255,0);
strokeWeight (2);
noFill();
beginShape ();
curveVertex(50,140);
curveVertex((-mouseX)+(mouseX*2),mouseY);
curveVertex(80,50);
curveVertex(50,110);
curveVertex(mouseX,mouseY);
endShape(CLOSE);

beginShape ();
curveVertex(50,140);
curveVertex((-mouseY)+(mouseY*2),mouseX);
curveVertex(80,50);
curveVertex(50,110);
curveVertex(mouseY,mouseX);
endShape(CLOSE);

}

     
     
     
     
     
     
     
     
     
     
     
     
     
     

APÉNDICE:

size (x,y);
background ();
stroke ();
nostroke ();
point (x,y);

 

 

 

 

 

 

 

 

 

 

 

 

 

www.citoplasma.com.mx 2007 Copyleft.