2021年10月14日 星期四

week 4. structural programming & basic form

Global variables v.s. local variables
subroutine calls



Manfred Mohr



William Kolomyjec

Computer Graphics & Art, 1977





Georg Nees 
the
T



  • Control





  • Iteration
  • Embedded Iteration
  • Conditionals 1
  • Conditionals 2
  • Logical Operators





  • Cybernetic Serendipity (1968): A Walkthrough With Jasia Reichardt

    (模控巧遇)

    EX:
      use subroutine call to perform 10 x 10 element-drawing.


    1. form: point, line, polygon, arc, eclipse, rect,...
    2. noLoop();  / redraw();

    void setup(){
      size(640, 360);
      background(0);
    }

    int gridSize = 40;

    void draw() {
    background(0); 
    stroke(200);
    noFill();
    for (int x = gridSize; x <= width - gridSize; x += gridSize) {
      for (int y = gridSize; y <= height - gridSize; y += gridSize) {
      
       rotateShape(x, y);
      
      }
    }

    }

    void rotateShape(int xloc, int yloc) {
      pushMatrix();
      translate(xloc, yloc);
     // rotate((frameCount / 8.0)+xloc+yloc+mouseX);
     rotate((mouseX/100)*frameCount / 8.0+xloc+yloc);
     rect(-10, -10, 20, 20);
     line(-10, -10, 10, 10);
      popMatrix();


    }


    References:
    https://processing.org/examples/star.html



    example #2:

    void setup(){
      size(640, 360);
      background(0);
    }

    int gridSize = 40;

    void draw() {
    background(0); 
    stroke(200);
    noFill();
    for (int x = gridSize; x <= width - gridSize; x += gridSize) {
      for (int y = gridSize; y <= height - gridSize; y += gridSize) {
       
       rotateShape(x, y);
       
      }
    }

    }

    void rotateShape(int xloc, int yloc) {
      pushMatrix();
      translate(xloc, yloc);
     rotate((frameCount / 8.0)+xloc+yloc);
     //rotate((mouseX/100)*frameCount / 8.0+xloc+yloc);
     beginShape();
    vertex(-10, -10);
    vertex(0, -10);
    vertex(0, 0);
    vertex(10, 0);
    vertex(10, 10);
    vertex(-10, 10);
    endShape(CLOSE);
     //rect(-10, -10, 20, 20);
    // line(-10, -10, 10, 10);
      popMatrix();


    }

    example #3:

    int gridSize = 100;
    void setup() {
    size(1000, 1000);
    stroke(255);
    background(0);
    frameRate(10);
    }
    void draw() {
    background(0);
    for (int i = 0; i <= width; i+= gridSize) {
    for (int j = 0; j <= height; j+= gridSize) {
    rect(i+gridSize/2 + random (40), j+gridSize/2, gridSize/4, gridSize/4);
    }
    }
    }

    example #4:

    int gridSize = 100;
    void setup() {
    size(1000, 1000);
    stroke(255);
    background(0);
    frameRate(5);
    noFill();
    }
    void draw() {
    background(0);
    for (int i = 0; i <= width; i+= gridSize) {
    for (int j = 0; j <= height; j+= gridSize) {
    drawGrid(i, j);
    }
    }
    }
    void drawGrid(int x, int y){
    int cellSize;
    for (int i = 0; i < 5; i++) {
    cellSize = (int) random(20, 60);
    rect(x+gridSize/2-cellSize/2, y+gridSize/2-cellSize/2, cellSize , cellSize, 6);
    }
    }


    Project 1:
    1. 選定一位美學運算的藝術家
    2. 手繪模仿其作品
    3. 用 processing 編碼產生方陣重複美學的作品,至少5件
    上傳到google drive (網址在 FB 公布)


    Deadline: Nov. 5, 2021


    沒有留言:

    張貼留言