02=coordinates=20130412

Upload: gene-kao

Post on 03-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 02=Coordinates=20130412

    1/19

    Processing

    02

    Coordinates, Shape Pr imi tives, Variable

  • 8/12/2019 02=Coordinates=20130412

    2/19

    Code ( ) Coding

    Encode Decode

    Macro

  • 8/12/2019 02=Coordinates=20130412

    3/19

    Coordinates

  • 8/12/2019 02=Coordinates=20130412

    4/19

    (0,0) 200

    200

    (200,200)size(200,200); background(255);

  • 8/12/2019 02=Coordinates=20130412

    5/19

    size(200,200);size(100,100);size(600,600);size(500,100);

    background(255); // background(0); //

    // size s // background b

  • 8/12/2019 02=Coordinates=20130412

    6/19

    28 = 256

    R: Red 28

    G: Green 28

    B: Blue 28 A: Alpha

    256 * 256 * 256 = 16,777,216

    H: Hue S: Saturation B: Brightness

  • 8/12/2019 02=Coordinates=20130412

    7/19

    colorMode(RGB);background(255,255,255); //

    background(255,255,0); //

    colorMode(HBS);

    background(210,100,40);

  • 8/12/2019 02=Coordinates=20130412

    8/19

    (0,0) 200

    200

    (200,200)size(200,200);background(255);line(10,10,10,190);

  • 8/12/2019 02=Coordinates=20130412

    9/19

    size(200,200);( 200, 200);

    background(255);( );

    line(10,10,10,190);(10,10,10,190);

  • 8/12/2019 02=Coordinates=20130412

    10/19

    size(500,100); background(255);

    fill(204);

    fill(255, 204 ); // alpha channelfill(255,255,155);fill(255,155,155, 75 ); // alpha channelnoFill();

    stroke(102);stroke(255,0,0);strokeWeight(6); noStroke();

    strokeCap(ROUND);strokeCap(SQUARE);strokeJoin(BEVEL);strokeJoin(MITER);strokeJoin(ROUND);

    smooth();noSmooth();

  • 8/12/2019 02=Coordinates=20130412

    11/19

    background(value1, value2, value3)

    fill(value1, value2, value3) fill(value1, value2, value3, alpha )

    stroke(value1)

    stroke(value1, alpha ) stroke(value1, value2, value3) stroke(value1, value2, value3, alpha )

    color(gray)color(gray, alpha )color(value1, value2, value3)color(value1, value2, value3, alpha )

  • 8/12/2019 02=Coordinates=20130412

    12/19

    Shape Primitives

  • 8/12/2019 02=Coordinates=20130412

    13/19

    point(x, y);

    line(x1, y1, x2, y2);triangle(x1, y1, x2, y2, x3, y3);quad(x1, y1, x2, y2, x3, y3, x4, y4);rect(x, y, width, height);ellipse(x, y, width, height);bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2);

    rectMode(CENTER);rectMode(CORNER);

    ellipseMode(RADIUS);ellipseMode(CORNER);

  • 8/12/2019 02=Coordinates=20130412

    14/19

    fill(0);noStroke();smooth();beginShape();

    vertex(10, 0);vertex(100, 30);vertex(90, 70);vertex(10, 90);

    vertex(50, 40);endShape();

    smooth();

    noFill(); beginShape();vertex(15, 30); // V1 (see p.76)

    bezierVertex(20, -5, 70, 5, 40, 35); // C1, C2, V2 bezierVertex(5, 70, 45, 105, 70, 70); // C3, C4, V3endShape();

    smooth();noStroke();

    beginShape();vertex(90, 39); // V1 (see p.76)

    bezierVertex(90, 39, 54, 17, 26, 83); // C1, C2, V2 bezierVertex(26, 83, 90, 107, 90, 39); // C3, C4, V3endShape();

    bezierVertex(cx1,cy1,cx2,cy2,x,y);

  • 8/12/2019 02=Coordinates=20130412

    15/19

    Variables

  • 8/12/2019 02=Coordinates=20130412

    16/19

    size(200,200);

    int x, y;x = 10; y = 180; rect(x,x,y,y);x = 20; y = 160; rect(x,x,y,y);x = 30; y = 140; rect(x,x,y,y);x = 40; y = 120; rect(x,x,y,y);x = 50; y = 100; rect(x,x,y,y);x = 60; y = 80; rect(x,x,y,y);x = 70; y = 60; rect(x,x,y,y);x = 80; y = 40; rect(x,x,y,y);x = 90; y = 20; rect(x,x,y,y);

  • 8/12/2019 02=Coordinates=20130412

    17/19

    size(200,200);

    background(255,0,0); //R G BnoStroke();

    int cl;

    cl = 0;fill(cl);rect(0,0,200,200);

    cl = 63;fill(cl);rect(20,20,160,160);

    cl = 127;fill(cl);rect(40,40,120,120);

    cl = 191;

    fill(cl);rect(60,60, 80, 80);

    cl = 255;fill(255);rect(80,80, 40, 40);

  • 8/12/2019 02=Coordinates=20130412

    18/19

    size(200,200);

    background(255,0,0); //R G BnoStroke();

    int cl, x, y;

    cl = 0;x = 0; y = 200;fill(cl);rect(x,x,y,y);

    cl = cl - 1 + 64;x = 20; y = 160;

    fill(cl);rect(x,x,y,y);

    cl = cl + 64;x = 40; y = 120;fill(cl);rect(x,x,y,y);

    cl = cl + 64;x = 60; y = 80;fill(cl);rect(x,x,y,y);

    cl = cl + 64;x = 80; y = 40;fill(255);rect(x,x,y,y);

    size(200,200);

    background(255,0,0); //R G BnoStroke();

    int cl, x, y;

    cl = 0;x = 00; y = 200;fill(cl,255,255);rect(x,x,y,y);

    cl = cl - 1 + 64;x = x + 20; y = y - 40;

    fill(cl,255,255);rect(x,x,y,y);

    cl = cl + 64;x = x + 20; y = y - 40;fill(cl,255,255);rect(x,x,y,y);

    cl = cl + 64;x = x + 20; y = y - 40;fill(cl,255,255);rect(x,x,y,y);

    cl = cl + 64;x = x + 20; y = y - 40;fill(cl,255,255);rect(x,x,y,y);

  • 8/12/2019 02=Coordinates=20130412

    19/19

    Ch. 2 - 404/12/2013