Processing
Processing
Processing est basado en JAVA y es un lenguaje de programacin de cdigo abierto y creado para las personas que deseen crear imgenes, animaciones e interacciones. Es similar al entorno de programacin de Energia, Arduino y Wiring.
y1
x2
y2
Returns
Colores en Processing
colorMode()
Syntax colorMode(mode) colorMode colorMode(mode, max) colorMode colorMode(mode, max1, max2, max3) colorMode
Parameters mode
int: Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness float: range for all color elements float: range for the red or hue depending on the current color mode float: range for the green or saturation depending on the current color mode float: range for the blue or brightness depending on the current color mode
max max1
max2
max3
Ejemplo 2
void setup() { size(200, 200); } void draw() { colorMode(RGB, 200); for (int i = 0; i < 200; i++) { //Realiza un barrido por filas for (int j = 0; j < 200; j++) { //Realiza un barrido por columnas stroke(i, j, 0); //Coloca el color de borde acorde a los 3 colores bsicos en RGB, //cambiar 0 por otro numero point(i, j); //Coloca un punto } } }
Curvas en Processing
curve()
Syntax curve(x1, y1, x2, y2, x3, y3, x4, y4 y4)
Parameters x1
float: coordinates for the beginning control point float: coordinates for the beginning control point float: coordinates for the first point float: coordinates for the first point float: coordinates for the second point float: coordinates for the second point float: coordinates for the ending control point float: coordinates for the ending control point
y1 x2 y2 x3 y3 x4 y4
Ejemplo 3
void setup () { size(200, 200); } void draw () { noFill(); stroke(255, 102, 0); curve(5, 26, 5, 26, 73, 24, 73, 61); stroke(0); curve(5, 26, 73, 24, 73, 61, 15, 65); stroke(255, 102, 0); curve(73, 24, 73, 61, 15, 65, 15, 65); }
Ejemplo 4
Crear una aplicacin grfica en Processing que permita cambiar el color de relleno en una figura geomtrica (cuadrado) cuando se presione un botn en la placa MSP430
Ejemplo 4
Crear una aplicacin grfica en Processing que permita encender el led de la placa MSP430 cuando se pase el puntero del ratn sobre la figura geomtrica. PROBAR CON LA HYPERTERMINAL
Ejemplo 5
Crear una aplicacin grfica en Processing que permita cambiar el color en una figura geomtrica (cuadrado) y su fondo cuando se regule la perilla mediante un potencimetro en la placa MSP430
Ejemplo 5
import processing.serial.*; Serial myPort; // Create object from Serial class int val=0; // Data received from the serial port void setup() { size(200, 200); String portName = Serial.list()[1]; //CAMBIAR PUERTO COM myPort = new Serial(this, portName, 9600); } void draw() { colorMode(RGB, 200); if ( myPort.available() > 0) { // If data is available, val = myPort.read(); //Almacena el valor leido en el puerto color bg = color(180, 50, (val-48)*25); //Configura un color 48)*25); fill(bg); //Relleno de la figura geomtrica background((val-48)*25); //Colorea el fondo 48)*25); rect(50, 50, 100, 100,5); //x,y, largo, alto desde el origen esquina superior izquierda } }