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

15,066 views

Published on

Published in: Technology, Business

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

  1. 1. ‣‣‣‣‣‣‣
  2. 2. ‣‣ setup( ) update( ) draw( )
  3. 3. ‣‣ setup( ) update( ) draw( )
  4. 4. ‣‣ setup( ) update( ) draw( )
  5. 5. ‣‣ setup( ) update( ) draw( )
  6. 6. ‣‣ setup( ) update( ) draw( )
  7. 7. ‣‣‣
  8. 8. ‣‣‣‣‣‣
  9. 9. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();!! ofVec2f pos; // ( )};
  10. 10. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();!! ofVec2f pos; // ( )}; setup, update, draw
  11. 11. ‣#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);! //}
  12. 12. ‣#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);! //}
  13. 13.
  14. 14. ‣ ‣ ofGetWidth() 0ofGetHeight()
  15. 15. ‣‣‣‣‣‣‣‣‣
  16. 16. ‣‣if ( ) {}
  17. 17. ‣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();} //
  18. 18. ‣#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);}
  19. 19.
  20. 20. ‣‣‣
  21. 21. ‣‣ (0, 0)
  22. 22. ‣‣ (0, 0)
  23. 23. ‣‣‣
  24. 24. ‣‣‣‣
  25. 25. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();!! float angle; //};
  26. 26. ‣#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);}
  27. 27.
  28. 28. ‣‣‣‣‣
  29. 29. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();!! float angle; //};
  30. 30. ‣#include "testApp.h"void testApp::setup(){! ofSetFrameRate(60);! // 60 (fps)! ofSetVerticalSync(true); //! ofBackgroundHex(0x000000); //! ofEnableBlendMode(OF_BLENDMODE_ADD);//}void testApp::update(){! angle += 10; //}
  31. 31. ‣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(); //}
  32. 32.
  33. 33. ‣‣‣
  34. 34. ‣#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}
  35. 35. ‣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(); //}
  36. 36.
  37. 37. ‣‣
  38. 38. ‣‣‣
  39. 39. ‣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();}
  40. 40.
  41. 41. ‣‣‣‣‣‣

×