Saturday, September 28, 2013

Processing 정리 & 복습


  • colorMode() function

colorMode(mode, range1, range2, range3)

colorMode(HSB, 360, 100, 100);
으로 맞추기
Hur, Saturation 이랑 Brightness 바꾸면 Brightness 효과 줄수 있다.

e.g)
//shift from blue to green in HSB mode
colorMode(HSB, 360, 100, 100);
for(int i=0; i<100; i++) {
float newHue = 200 - (i*1.2);
stroke(newHue, 70, 80);
line(i, 0,i, 100);
}

// change saturation, hue and brightness constant
colorMode(HSB);
for (int i = 0; i<100; i++) {
  stroke(132, i*2.5, 204);
  line(i,0,i, 100);
}


  • println (console) : 현재 프로그램 진행 상황을 알려주기 위한 키
    Because it is important to understand what is happening inside the machine, the functions pring() and println() can be used to display data while a program is running.
    The consule can be used to display a variable, confirm an event
  • Variables

    There are many different kinds of data, such as numbers, letters, words, colors, and it is necessary to specify the type of data so the computer knows how to correctly interpret the bits.
    A variable is a container for storing data. Variables allow a data elements to be reused many times within a program.
  • Numeric data : integer(whole number), and floating point number(decimal point)
    float : approximate analog ro continuous values because they have decimal resolution.

    boolean : true / false. boolean variables are often used to make decisions about which lines of code are run and which are ignored.

    e.g )
    int x = 50;
    float y = 12.6;
    boolean b = true;

    float x, ,y , z;
    x = -3.9
    y = 10.1;
    z= 124.23
  • = : assignment operator
  • short cuts

    ++ / -- : plus 1 / minus 1
    += :  e.g) x += 5 : x = x+5
    -= :  e.g) x -= 5 : x = x -5
    *= :  e.g) x *= 2 : x = x * 2
    /= :  e.g) x /= 2 : x = x / 2
  • Decisions
    >    <
    >=   <=
    ==
    if, else, {}
    || : OR
    && : AND
    ! : NOT

    != : not equal to
  • Conditionals - IF
    int x =
    if( ) {
      if ( ) {
       } else ( ) {
    }
    } else () {
    }

    ---
    int x =
    if ( ) { }
    else if () {}
    else () {}
  • Repetition (Iteration)
    for (init ; test ; update) {
    statements }

No comments:

Post a Comment