# Sesc Av. Paulista - Linguagens de programação: Por onde eu começo? **Processing** ### `hackmd.io/@villares/sesc-processing` (esta página) ### [link para os slides](https://docs.google.com/presentation/d/1AkmysG8q-q6tz5fb-sS1NLJwIkVp6TZpLmySrhO-zTk/edit?usp=sharing) ## Para instalar e experimentar em casa - Processing IDE, baixar em https://processing.org - Referência https://processing.org/reference - Livro https://codigotranscendente.github.io/livro/ - Comunidade de programação criativa : https://pcd.encontrosdigitais.com.br ### Referencias artísticas de desenho com programação - Georg Nees - Obra "Schotter" https://collections.vam.ac.uk/item/O221321/schotter-print-nees-georg/ - Vera Molnar - randomness https://vimeo.com/372579247 ### Material de referência sobre Procesing - Livro [O código transcendente](https://codigotranscendente.github.io/livro/about.html) de Mateus Berruezo - [Programação Criativa](http://arteprog.space/programacao-criativa) de Monica Rizzolli e Alexandre Villares - [Guia de programação em Processing](https://www.ranoya.com/aulas/designgenerativo/playgroundDocs/introProcessing.php?theme=dgen&elementos=processing), Prof. Guilherme Ranoya (UFPE). - [Tradução da referência da linguagem - versão 1.0 (2005)](http://www.dainf.ct.utfpr.edu.br/~merkle/processing/reference/ptBR/index.html), Prof. Luiz Merkle (UFTPR) ## Exemplos ![](https://lugaralgum.com/hackmd/Pey1K9e.png) ```java size(400, 400); // Tamanho da área de desenho background(150, 150, 200); //fundo (vermelho, verde, azul) fill(120, 100, 100, 130); // cor de preenchimento rect(30, 40, 100, 150); // x, y, w, h triangle(100, 100, 300, 100, 200, 300); ``` ![](https://lugaralgum.com/hackmd/AQWqR8E.png) ``` java void setup() { size(400, 400); } void draw() { float sorteio = random(50, 250); //background(150, 150, 200); // vermelho, verde, azul fill(120, 100, sorteio); rect(mouseX, mouseY, sorteio, 150); // x, y, w, h //triangle(100, 100, 300, 100, 200, 300); } ``` ![](https://lugaralgum.com/hackmd/IHBCQFQ.png) ```java void setup() { size(800, 800); background(250, 250, 220); } void draw() { float vermelho = random(128, 256); float verde = random(128, 256); float azul = 128; fill(vermelho, verde, azul); noStroke(); if (mousePressed) { circle(mouseX, mouseY, random(20, 90)); //circle(mouseX, mouseY, 20); } } ``` ![](https://lugaralgum.com/hackmd/tdUq7my.png) Precisa baixar a fonte Tomorrow e copiar na pasta `data` dentro do seu projeto. ```java void setup() { size(800, 800); background(250, 250, 220); PFont f = createFont("Tomorrow-Bold.ttf", 80); textFont(f); textSize(80); } void draw() { float vermelho = random(128, 256); float verde = random(128, 256); float azul = 128; fill(vermelho, verde, azul); noStroke(); if (mousePressed) { float tam = random(-50, 50); text("fim de semana", mouseX, mouseY); //triangle(mouseX, mouseY, // mouseX + 50, mouseY, // mouseX + tam , mouseY + 50 // ); } } void keyPressed() { if (key == ' ') { background(250, 250, 220); } else if (key == 's') { saveFrame("####.png"); } } ``` ### Recriando "schotter" ```pde= int cols = 10; int rows = 15; int tam = 50; int margem = 50; void setup() { size(600, 900); rectMode(CENTER); noLoop(); noFill(); } void cascalho(float x, float y, float w, float h, float rot) { pushMatrix(); translate(x, y); rotate(rot); rect(0, 0, w, h); popMatrix(); } void draw() { background(240); int counter = 0; for (int j = 0; j < rows; j++) { for (int i = 0; i < cols; i++) { float varia = counter / 5; float oy = random(-varia, varia); float ox = random(-varia, varia); float y = margem + tam * j + tam / 2 + oy; float x = margem + tam * i + tam / 2 + ox; float angulo = radians(random(-varia, varia)); cascalho(x, y, tam, tam, angulo); counter++; } } } void keyPressed(){ redraw(); } ``` ### exemplo árvore recursiva ```pde= float ang = 15; float encurtar = 0.90; int ra = 3; int en = 5; int seed = 1; void setup() { size(900, 900); stroke(0, 100); //noLoop(); } void galho(float tam){ strokeWeight(tam / 10); line(0, 0, 0, -tam); if (tam > 20){ // && random(10) < 9) { pushMatrix(); translate(0, -tam); float a1 = ang + random(-ra, ra); rotate(radians(a1)); galho(tam * encurtar - random(en)); rotate(radians(-a1)); float a2 = ang + random(-ra, ra); rotate(radians(-a2)); galho(tam * encurtar - random(en)); popMatrix(); } } void draw() { ang = frameCount / 30.0; println(ang); randomSeed(seed); background(240); translate(width / 2, height * 0.85); galho(80); saveFrame("####.png"); } void keyPressed(){ seed++; println(seed); } ```