‣
‣


‣


‣
‣

‣
‣
‣
‣



    setup( )



    update( )



    draw( )
‣
‣



    setup( )



    update( )



    draw( )
‣
‣



    setup( )



    update( )



    draw( )
‣
‣



    setup( )



    update( )



    draw( )
‣
‣



    setup( )



    update( )



    draw( )
‣
‣
‣
‣


‣
‣


‣
‣

‣
‣

#pragma once

#include "ofMain.h"

class testApp : public ofBaseApp{
!
public:
! void setup();
! void update();
! void draw();
!
! ofVec2f pos; //                   (   )
};
‣

#pragma once

#include "ofMain.h"

class testApp : public ofBaseApp{
!
public:
! void setup();
! void update();
! void draw();
!
! ofVec2f pos; //                   (   )
};
     setup, update, draw
‣

#include "testApp.h"

void testApp::setup(){
! ofSetFrameRate(60);!    //         60   (fps)
!   ofBackgroundHex(0x000000); //
!   //
!   pos.x = ofGetWidth()/2;
!   pos.y = ofGetHeight()/2;
}

void testApp::update(){
! //
!   pos.x += 4.0; //pos.x = pos.x + 3.0
!   pos.y += 3.0; //pos.y = pos.y + 4.0
}

void testApp::draw(){
! ofSetHexColor(0x3399ff); //
!   ofCircle(pos.x, pos.y, 20);!    //
}
‣

#include "testApp.h"

void testApp::setup(){
! ofSetFrameRate(60);!    //         60   (fps)
!   ofBackgroundHex(0x000000); //
!   //
!   pos.x = ofGetWidth()/2;
!   pos.y = ofGetHeight()/2;
}

void testApp::update(){
! //
!   pos.x += 4.0; //pos.x = pos.x + 3.0
!   pos.y += 3.0; //pos.y = pos.y + 4.0
}

void testApp::draw(){
! ofSetHexColor(0x3399ff); //
!   ofCircle(pos.x, pos.y, 20);!    //
}
‣
‣
 ‣
                ofGetWidth()
           0




ofGetHeight()
‣


‣
‣


‣
‣

‣
‣


‣
‣
‣


‣

if (   ) {


}
‣

if (pos.x > ofGetWidth()) {pos.x = 0;}   //
if (pos.x < 0) {pos.x = ofGetWidth();}   //
if (pos.y > ofGetHeight()) {pos.y = 0;} //
if (pos.y < 0) {pos.y = ofGetHeight();} //
‣

#include "testApp.h"

void testApp::setup(){
! ofSetFrameRate(60);
! ofBackgroundHex(0x000000);
! pos.x = ofGetWidth()/2;
! pos.y = ofGetHeight()/2;
}

void testApp::update(){
! pos.x += 4.0;
! pos.y += 3.0;
! if (pos.x > ofGetWidth()) {pos.x = 0;}     //
!   if (pos.x < 0) {pos.x = ofGetWidth();}   //
!   if (pos.y > ofGetHeight()) {pos.y = 0;} //
!   if (pos.y < 0) {pos.y = ofGetHeight();} //
}

void testApp::draw(){
! ofSetHexColor(0x3399ff);
! ofCircle(pos.x, pos.y, 20);
}
‣
‣



‣
‣
‣
‣




    (0, 0)
‣
‣




    (0, 0)
‣


‣
‣
‣


‣
‣
‣
‣

#pragma once

#include "ofMain.h"

class testApp : public ofBaseApp{
!
public:
! void setup();
! void update();
! void draw();
!
! float angle; //
};
‣
#include "testApp.h"

void testApp::setup(){
! ofSetFrameRate(60);!    //        60     (fps)
!   ofBackgroundHex(0x000000); //
!   //
!   ofSetRectMode(OF_RECTMODE_CENTER);
}

void testApp::update(){
! angle += 10; //
}

void testApp::draw(){
! //
!   ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
!   ofRotateZ(angle); //
!   //
!   ofSetHexColor(0x3399ff);
!   ofRect(0, 0, 200, 200);
}
‣
‣


‣
‣
‣
‣
‣

#pragma once

#include "ofMain.h"

class testApp : public ofBaseApp{
!
public:
! void setup();
! void update();
! void draw();
!
! float angle; //
};
‣
#include "testApp.h"

void testApp::setup(){
! ofSetFrameRate(60);!    //        60       (fps)
!   ofSetVerticalSync(true); //
!   ofBackgroundHex(0x000000); //
!   ofEnableBlendMode(OF_BLENDMODE_ADD);//
}

void testApp::update(){
! angle += 10; //
}
‣
void testApp::draw(){
! //
!   ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
!   ofRotateZ(angle); //

!   ofPushMatrix(); //
!
!   //   1
!   ofSetHexColor(0xff0000);
!   ofCircle(80, 0, 100);
!   ofRotateZ(120); //
!   //   2
!   ofSetHexColor(0x00ff00);
!   ofCircle(80, 0, 100);
!   ofRotateZ(120); //
!   //   3
!   ofSetHexColor(0x0000ff);
!   ofCircle(80, 0, 100);
!
!   ofPopMatrix(); //
}
‣
‣



‣


‣
‣
#include "testApp.h"

void testApp::setup(){
! ofSetFrameRate(60);!    //        60       (fps)
!   ofSetVerticalSync(true); //
!   ofBackgroundHex(0x000000); //
!   ofEnableBlendMode(OF_BLENDMODE_ADD);//
!   ofSetCircleResolution(64); //
}

void testApp::update(){
! angle += mouseY / 4.0; //         Y
}
‣
void testApp::draw(){
! //
!   ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
!   ofRotateZ(angle); //

!   ofPushMatrix(); //
!
!   //   1
!   ofSetHexColor(0xff0000);
!   ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0);
!   ofRotateZ(120); //
!   //   2
!   ofSetHexColor(0x00ff00);
!   ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0);
!   ofRotateZ(120); //
!   //   3
!   ofSetHexColor(0x0000ff);
!   ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0);
!
!   ofPopMatrix(); //
}
‣
‣


‣
‣
‣
‣
‣
void testApp::draw(){
! //
!   ofTranslate(ofGetWidth()/2, ofGetHeight()/2);

!   ofRotateX(mouseY);
!   ofRotateZ(angle);

!   ofPushMatrix();

!   ofSetHexColor(0xff0000);
!   ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0);
!   ofRotateZ(120);
!   ofSetHexColor(0x00ff00);
!   ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0);
!   ofRotateZ(120);
!   ofSetHexColor(0x0000ff);
!   ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0);
!
!   ofPopMatrix();
}
‣
‣
‣


‣
‣


‣

‣

openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B

  • 2.
  • 4.
    ‣ ‣ setup( ) update( ) draw( )
  • 5.
    ‣ ‣ setup( ) update( ) draw( )
  • 6.
    ‣ ‣ setup( ) update( ) draw( )
  • 7.
    ‣ ‣ setup( ) update( ) draw( )
  • 8.
    ‣ ‣ setup( ) update( ) draw( )
  • 9.
  • 11.
  • 12.
    ‣ #pragma once #include "ofMain.h" classtestApp : public ofBaseApp{ ! public: ! void setup(); ! void update(); ! void draw(); ! ! ofVec2f pos; // ( ) };
  • 13.
    ‣ #pragma once #include "ofMain.h" classtestApp : public ofBaseApp{ ! public: ! void setup(); ! void update(); ! void draw(); ! ! ofVec2f pos; // ( ) }; setup, update, draw
  • 14.
    ‣ #include "testApp.h" void testApp::setup(){ !ofSetFrameRate(60);! // 60 (fps) ! ofBackgroundHex(0x000000); // ! // ! pos.x = ofGetWidth()/2; ! pos.y = ofGetHeight()/2; } void testApp::update(){ ! // ! pos.x += 4.0; //pos.x = pos.x + 3.0 ! pos.y += 3.0; //pos.y = pos.y + 4.0 } void testApp::draw(){ ! ofSetHexColor(0x3399ff); // ! ofCircle(pos.x, pos.y, 20);! // }
  • 15.
    ‣ #include "testApp.h" void testApp::setup(){ !ofSetFrameRate(60);! // 60 (fps) ! ofBackgroundHex(0x000000); // ! // ! pos.x = ofGetWidth()/2; ! pos.y = ofGetHeight()/2; } void testApp::update(){ ! // ! pos.x += 4.0; //pos.x = pos.x + 3.0 ! pos.y += 3.0; //pos.y = pos.y + 4.0 } void testApp::draw(){ ! ofSetHexColor(0x3399ff); // ! ofCircle(pos.x, pos.y, 20);! // }
  • 16.
  • 17.
    ‣ ‣ ofGetWidth() 0 ofGetHeight()
  • 18.
  • 19.
  • 20.
    ‣ if (pos.x >ofGetWidth()) {pos.x = 0;} // if (pos.x < 0) {pos.x = ofGetWidth();} // if (pos.y > ofGetHeight()) {pos.y = 0;} // if (pos.y < 0) {pos.y = ofGetHeight();} //
  • 21.
    ‣ #include "testApp.h" void testApp::setup(){ !ofSetFrameRate(60); ! ofBackgroundHex(0x000000); ! pos.x = ofGetWidth()/2; ! pos.y = ofGetHeight()/2; } void testApp::update(){ ! pos.x += 4.0; ! pos.y += 3.0; ! if (pos.x > ofGetWidth()) {pos.x = 0;} // ! if (pos.x < 0) {pos.x = ofGetWidth();} // ! if (pos.y > ofGetHeight()) {pos.y = 0;} // ! if (pos.y < 0) {pos.y = ofGetHeight();} // } void testApp::draw(){ ! ofSetHexColor(0x3399ff); ! ofCircle(pos.x, pos.y, 20); }
  • 22.
  • 24.
  • 25.
    ‣ ‣ (0, 0)
  • 26.
    ‣ ‣ (0, 0)
  • 27.
  • 28.
  • 29.
    ‣ #pragma once #include "ofMain.h" classtestApp : public ofBaseApp{ ! public: ! void setup(); ! void update(); ! void draw(); ! ! float angle; // };
  • 30.
    ‣ #include "testApp.h" void testApp::setup(){ !ofSetFrameRate(60);! // 60 (fps) ! ofBackgroundHex(0x000000); // ! // ! ofSetRectMode(OF_RECTMODE_CENTER); } void testApp::update(){ ! angle += 10; // } void testApp::draw(){ ! // ! ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ! ofRotateZ(angle); // ! // ! ofSetHexColor(0x3399ff); ! ofRect(0, 0, 200, 200); }
  • 31.
  • 32.
  • 33.
    ‣ #pragma once #include "ofMain.h" classtestApp : public ofBaseApp{ ! public: ! void setup(); ! void update(); ! void draw(); ! ! float angle; // };
  • 34.
    ‣ #include "testApp.h" void testApp::setup(){ !ofSetFrameRate(60);! // 60 (fps) ! ofSetVerticalSync(true); // ! ofBackgroundHex(0x000000); // ! ofEnableBlendMode(OF_BLENDMODE_ADD);// } void testApp::update(){ ! angle += 10; // }
  • 35.
    ‣ void testApp::draw(){ ! // ! ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ! ofRotateZ(angle); // ! ofPushMatrix(); // ! ! // 1 ! ofSetHexColor(0xff0000); ! ofCircle(80, 0, 100); ! ofRotateZ(120); // ! // 2 ! ofSetHexColor(0x00ff00); ! ofCircle(80, 0, 100); ! ofRotateZ(120); // ! // 3 ! ofSetHexColor(0x0000ff); ! ofCircle(80, 0, 100); ! ! ofPopMatrix(); // }
  • 36.
  • 37.
  • 38.
    ‣ #include "testApp.h" void testApp::setup(){ !ofSetFrameRate(60);! // 60 (fps) ! ofSetVerticalSync(true); // ! ofBackgroundHex(0x000000); // ! ofEnableBlendMode(OF_BLENDMODE_ADD);// ! ofSetCircleResolution(64); // } void testApp::update(){ ! angle += mouseY / 4.0; // Y }
  • 39.
    ‣ void testApp::draw(){ ! // ! ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ! ofRotateZ(angle); // ! ofPushMatrix(); // ! ! // 1 ! ofSetHexColor(0xff0000); ! ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0); ! ofRotateZ(120); // ! // 2 ! ofSetHexColor(0x00ff00); ! ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0); ! ofRotateZ(120); // ! // 3 ! ofSetHexColor(0x0000ff); ! ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0); ! ! ofPopMatrix(); // }
  • 40.
  • 41.
  • 42.
  • 43.
    ‣ void testApp::draw(){ ! // ! ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ! ofRotateX(mouseY); ! ofRotateZ(angle); ! ofPushMatrix(); ! ofSetHexColor(0xff0000); ! ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0); ! ofRotateZ(120); ! ofSetHexColor(0x00ff00); ! ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0); ! ofRotateZ(120); ! ofSetHexColor(0x0000ff); ! ofCircle(mouseX / 3.0, 0, 300 - mouseX / 6.0); ! ! ofPopMatrix(); }
  • 44.
  • 45.