GMU:Algorithmic Art/Jonas Obertüfer/for computers

From Medien Wiki

blib blub.


Algorithm for Computers 1 — 02.11.18

Result Algorithm
incoming soon ok cool

Sweater Pattern

Result Algorithm
 

 

/*
Nested for loops practice
using: 
 - beginShape()
 - endshape()
 - strokeWeight(15.0) -> for thick fat lines
 - strokeJoin(MITER); -> for edgy line connections :)
 
this should be a reproduction of pattern on one of my sweaters
(-> See Picture on the left) but without the mirroring.
 
*/

int elementsPerSide = 10;
int gap = 50;

void setup(){
  size(550, 550);
  stroke(28,42,76);
}

void draw(){
  background(255);
    
  for(int i=1; i<=elementsPerSide; i++){
    for(int j=1; j<=elementsPerSide; j++){
      
      int xPos = i*gap;
      int yPos = j*gap;
      
      noFill();
      strokeWeight(15.0);
      strokeJoin(MITER);
      beginShape();
      vertex(xPos-25,yPos+25);
      vertex(xPos,yPos);
      vertex(xPos+25,yPos+25);
      endShape();
      
    }
  }
  
}

graue brühe

v1:

Result Algorithm
 
ArrayList<Brush> brushes; 

void setup() {
  size(600,600);
  background(255);
  
  colorMode(HSB);
  brushes = new ArrayList<Brush>();
  
}

void draw() {
   
  for (Brush brush : brushes) {
    brush.paint();
  }
}

void mouseClicked() {
  brushes.add(new Brush());
}

class Brush {
  float angle;
  int components[];
  float x, y;
  color clr;

  Brush() {
    angle = random(TWO_PI);
    x = mouseX;
    y = mouseY;
    clr = color(0, 0, random(100), 5);
    components = new int[4];
    for (int i = 0; i < 4; i++) {
      components[i] = int(random(1, 4));
    }
  }

  void paint() {
    float a = 0;
    float r = 0;
    float x1 = x;
    float y1 = y;
    float u = random(0.5, 1);
    

    fill(clr);
    noStroke();    
    
    ellipse(x, y, random(50,150), random(50,150));

    if (x < 0 || x > width ||y < 0 || y > height) {
      angle += HALF_PI;
    }

    x += 3 * cos(angle);
    y += 3 * sin(angle); 
    angle += random(-0.15, 0.15);
  }
}

v2:

Result Algorithm
 
ArrayList<Brush> brushes; 

void setup() {
  size(600,600);
  background(255);
  
  colorMode(HSB);
  brushes = new ArrayList<Brush>();
  
}

void draw() {
   
  for (Brush brush : brushes) {
    brush.paint();
  }
}

void mouseClicked() {
  brushes.add(new Brush());
}

class Brush {
  float angle;
  int components[];
  float x, y;
  color clr;

  Brush() {
    angle = random(TWO_PI);
    x = mouseX;
    y = mouseY;
    clr = color(random(255), 0, random(255), 5);
    components = new int[4];
    for (int i = 0; i < 4; i++) {
      components[i] = int(random(1, 4));
    }
  }

  void paint() {
    float a = 0;
    float r = 0;
    float x1 = x;
    float y1 = y;
    float u = random(0.5, 1);
    

    fill(clr);
    noStroke();    
    
    ellipse(x, y, random(50,250), random(50,250));

    if (x < 0 || x > width ||y < 0 || y > height) {
      angle += HALF_PI;
    }

    x += 3 * cos(angle);
    y += 3 * sin(angle); 
    angle += random(-0.15, 0.15);
  }