Advertisement
Iqor

Aula04

Mar 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. import controlP5.*;
  2.  
  3. int m[][];
  4.  
  5. ControlP5 guiH, guiV, guiTQ;
  6.  
  7. int quantidadeHorizontal = 0;
  8. int quantidadeVertical = 0;
  9. int tamanhoQuadrado = 50;
  10.  
  11.  
  12. void setup() {
  13.   size(500, 500);
  14.   rectMode(CENTER);
  15.  
  16.   guiH = new ControlP5(this);
  17.  
  18.   guiH.addSlider("quantidadeHorizontal")
  19.     .setRange(5, 100)
  20.     .setValue(quantidadeHorizontal)
  21.     .setPosition(10, 475)
  22.     .setSize(200, 20);
  23.  
  24.   guiV = new ControlP5(this);
  25.  
  26.   guiV.addSlider("quantidadeVertical")
  27.     .setRange(5, 100)
  28.     .setValue(quantidadeVertical)
  29.     .setPosition(10, 450)
  30.     .setSize(200, 20);
  31.  
  32.   guiTQ = new ControlP5(this);
  33.  
  34.   guiTQ.addSlider("tamanhoQuadrado")
  35.     .setRange(5, 100)
  36.     .setValue(tamanhoQuadrado)
  37.     .setPosition(10, 425)
  38.     .setSize(200, 20);
  39. }
  40.  
  41. void draw() {
  42.   background(128);
  43.   criaArte(quantidadeHorizontal, quantidadeVertical, tamanhoQuadrado);
  44. }
  45.  
  46. void criaArte(int quantidadeHorizontal, int quantidadeVertical, int tamanhoQuadrado) {
  47.  
  48.   int[][] matriz = new int[quantidadeHorizontal][quantidadeVertical];
  49.  
  50.  
  51.   for (int i = 0; i < quantidadeHorizontal; i++) {
  52.     for (int j = 0; j < quantidadeVertical; j++) {
  53.       bloco(i * tamanhoQuadrado + tamanhoQuadrado/2, j * tamanhoQuadrado + tamanhoQuadrado/2, tamanhoQuadrado);
  54.     }
  55.   }
  56. }
  57.  
  58.  
  59. void bloco(int x, int y, int l) {
  60.   //fill(random(0, 255), random(0, 255), random(0, 255));
  61.   rect(x, y, l, l);
  62.   circulo(x, y, l/2);
  63.   circulo(x, y, l/3);
  64.   circulo(x, y, l/6);
  65. }
  66. void circulo(int x, int y, int r) {
  67.   //fill(random(0, 255), random(0, 255), random(0, 255));
  68.   ellipse(x, y, 2*r, 2*r);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement