Компьютерная графика в Processing, часть 6. Взаимодействие.

  • Published on
    17-Jul-2015

  • View
    321

  • Download
    4

Embed Size (px)

Transcript

  • Jordi Linares i PellicerEscola Politcnica Superior dAlcoiDep. de Sistemes Informtics i Computacijlinares@dsic.upv.eshttp://www.dsic.upv.es/~jlinares

  • processing : -,

    .

    ; .

    draw(). , .

    - , .

  • mouseX, mouseY

    : mouseX => x mouseY => y

  • // , void setup(){ size(500, 500); noStroke(); // background(0);}

    void draw(){ // fill(0, 1); rect(0, 0, width, height); // , // fill(255); ellipse(mouseX, mouseY, 50, 50);}

  • pmouseX, pmouseY

    : pmouseX => x pmouseY => y

  • // void setup(){ size(500, 500); background(0); stroke(255); strokeWeight(2); smooth(); // antialiasing}

    void draw(){ line(pmouseX, pmouseY, mouseX, mouseY);}

  • mousePressed

    TRUE, , FALSE

  • // void setup(){ size(500, 500); background(0); stroke(255); strokeWeight(2); smooth(); // antialiasing}

    void draw(){ if (mousePressed) line(pmouseX, pmouseY, mouseX, mouseY);}

  • mouseButton

    LEFT, RIGHT CENTER ,

    mousePressed

  • // void setup(){ size(500, 500); background(0); strokeWeight(2); smooth(); // antialiasing}

    void draw(){ if (mousePressed) { if (mouseButton == LEFT) { // stroke(255); strokeWeight(2); } else { // stroke(0); strokeWeight(4); } line(mouseX, mouseY, pmouseX, pmouseY); }}

  • keyPressed

    TRUE, key

    : BACKSPACE,TAB, ENTER, RETURN, ESC DELETE.

    CODED, keyCode , : UP,DOWN,LEFT,RIGHT,ALT,CONTROL,SHIFT

    KeyPressed.

  • -

    (callback functions), , .

    , void

    .

  • void mousePressed()

    , mouseButton , .

    ( , , )

    void mouseReleased()

    , - , .

    mouseButton ,

  • void mouseClicked()

    , .

    mouseButton

    mousePressed() mouseReleased()

  • void mouseMoved()

    , .

    mouseX mouseY ,

    void mouseDragged()

    , ( mouseButton , )

    mouseX mouseY ,

  • void keyPressed()

    , key, , (keyCode )

    void keyReleased()

    , key, , (keyCode )

  • void keyTyped()

    , ( , )

    keyPressed() keyReleased()

    keyTyped(),

    Control, Alt Shift

  • // color colorStroke = color(255, 0, 0);

    void setup(){ size(500, 500); background(0); strokeWeight(2); smooth(); // antialiasing}

    void draw(){ if (mousePressed) { if (mouseButton == LEFT) { // stroke(colorStroke); strokeWeight(2); } else { stroke(0); // strokeWeight(4); } line(mouseX, mouseY, pmouseX, pmouseY); }}

    void keyPressed(){ switch (key) { case 'r': case 'R': colorStroke = color(255,0,0); break; case 'g': case 'G': colorStroke = color(0,255,0); break; case 'b': case 'B': colorStroke = color(0,0,255); break; } }

  • 6-1

    (g)

    (r)

    F = m (g + r)a = r + gv(t+1) = v(t) + ae(t+1) = e(t) + v(t+1)

  • , .

    ( )

    UP, , : ( / , )

    LEFT RIGHT ( , )

    6-1

  • , : . , , .

    ,

    , (: , )

    , , , ,

    draw()

    6-1

  • 6-1

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Recommended

View more >