‣‣‣
‣    ‣    ‣    ‣    ‣‣
‣‣‣    ‣    ‣    ‣
‣‣‣
‣             ::    (   1,   2,    3...){}‣int testApp::poweroftwo(int a){! return a * a;}‣
‣‣‣‣‣‣ofPoint interpolateByPct(float pct);
‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();! vo...
‣#include "testApp.h"void testApp::setup(){!   ofBackground(0, 0, 0);!   ofSetFrameRate(60);!   ofSetRectMode(OF_RECTMODE_...
‣‣‣    ‣    ‣
‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();!! v...
‣#include "testApp.h"void testApp::setup(){!   ofSetBackgroundAuto(false);!   ofSetVerticalSync(true);!   ofEnableAlphaBle...
‣ofPoint testApp::interpolateByPct(float _pct){! float pct = _pct;! ofPoint pos;! pos.x = (1-pct) * startPos.x + (pct) * e...
‣
‣‣‣‣‣‣‣
‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();! vo...
‣#include "testApp.h"void testApp::setup(){! ofSetBackgroundAuto(false);! ofSetVerticalSync(true);! ofEnableAlphaBlending(...
‣void testApp::draw(){! fadeToBlack();! ofSetRectMode(OF_RECTMODE_CENTER);! ofSetColor(31, 127, 255);! ofRect(currentPos.x...
‣
‣
‣‣    ‣    ‣‣    ‣    ‣
‣‣    ‣    ‣    ‣    ‣    ‣    ‣    ‣    ‣    ‣‣‣
‣‣    ‣    ‣    ‣    ‣    ‣
‣
‣000100 IDENTIFICATION DIVISION.000200 PROGRAM-ID.      HELLOWORLD.000300 DATE-WRITTEN.    02/05/96       21:04.000400*AUT...
‣‣    ‣    ‣    ‣
‣
‣    ‣    ‣    ‣    ‣
‣‣‣‣‣‣
‣
‣    ‣    ‣    ‣    ‣    ‣
‣‣‣
‣‣
‣
To invent programs, you need to be able to capture abstractions and ex    design. It’s the job of a programming language t...
‣‣‣
‣‣‣‣    getName()   getName()
‣    ‣    ‣
‣‣‣
‣‣
‣
‣‣‣    ‣    ‣    ‣    ‣    ‣‣    ‣    ‣
‣‣‣    ‣‣    ‣‣    ‣
‣    ‣    ‣‣‣
‣‣
‣
‣
‣
‣
‣
‣‣
‣#pragma once#include "ofMain.h"#include "Rectangle.h"class testApp : public ofBaseApp{!public:! void setup();! void updat...
‣#include "testApp.h"void testApp::setup(){! ofSetBackgroundAuto(false);! ofSetVerticalSync(true);! ofEnableAlphaBlending(...
‣#pragma once#include "ofMain.h"class Rectangle {public:! void draw();! ofPoint pos;};
‣#include "rectangle.h"void Rectangle::draw() {! ofFill();! ofSetRectMode(OF_RECTMODE_CENTER);! ofSetColor(31,127,255);! o...
‣
‣‣    ‣‣    ‣    ‣    ‣    ‣    ‣
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
Upcoming SlideShare
Loading in …5
×

openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII

6,328 views

Published on

Published in: Education, Technology, Business
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,328
On SlideShare
0
From Embeds
0
Number of Embeds
2,655
Actions
Shares
0
Downloads
108
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII

  1. 1. ‣‣‣
  2. 2. ‣ ‣ ‣ ‣ ‣‣
  3. 3. ‣‣‣ ‣ ‣ ‣
  4. 4. ‣‣‣
  5. 5. ‣ :: ( 1, 2, 3...){}‣int testApp::poweroftwo(int a){! return a * a;}‣
  6. 6. ‣‣‣‣‣‣ofPoint interpolateByPct(float pct);
  7. 7. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();! void keyPressed (int key);! void keyReleased(int key);! void mouseMoved(int x, int y );! void mouseDragged(int x, int y, int button);! void mousePressed(int x, int y, int button);! void mouseReleased(int x, int y, int button);! void windowResized(int w, int h);! void dragEvent(ofDragInfo dragInfo);! void gotMessage(ofMessage msg);!! float pct;! ofPoint currentPos, startPos, endPos;! ofPoint interpolateByPct(float pct);};
  8. 8. ‣#include "testApp.h"void testApp::setup(){! ofBackground(0, 0, 0);! ofSetFrameRate(60);! ofSetRectMode(OF_RECTMODE_CENTER);! startPos.set(10, 400);! endPos.set(1000, 300);! pct = 0;}void testApp::update(){! pct += 0.01f;! if (pct > 1) {! ! pct = 0;! }!! currentPos = interpolateByPct(pct);}void testApp::draw(){! ofSetColor(31, 127, 255);! ofRect(currentPos.x, currentPos.y, 20, 20);}ofPoint testApp::interpolateByPct(float pct){! ofPoint pos;! pos.x = (1-pct) * startPos.x + (pct) * endPos.x;! pos.y = (1-pct) * startPos.y + (pct) * endPos.y;! return pos;}
  9. 9. ‣‣‣ ‣ ‣
  10. 10. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();!! void keyPressed (int key);! void keyReleased(int key);! void mouseMoved(int x, int y );! void mouseDragged(int x, int y, int button);! void mousePressed(int x, int y, int button);! void mouseReleased(int x, int y, int button);! void windowResized(int w, int h);! void dragEvent(ofDragInfo dragInfo);! void gotMessage(ofMessage msg);!! float pct;! ofPoint currentPos, startPos, endPos;! ofPoint interpolateByPct(float pct);! void fadeToBlack();};
  11. 11. ‣#include "testApp.h"void testApp::setup(){! ofSetBackgroundAuto(false);! ofSetVerticalSync(true);! ofEnableAlphaBlending();! ofSetFrameRate(60);! ofBackground(0, 0, 0);! startPos.set(10, 400);! endPos.set(1000, 300);! pct = 0;}void testApp::update(){! pct += 0.01f;! if (pct > 1) {! ! pct = 0;! }!! currentPos = interpolateByPct(pct);}void testApp::draw(){! fadeToBlack();! ofSetRectMode(OF_RECTMODE_CENTER);! ofSetColor(31, 127, 255);! ofRect(currentPos.x, currentPos.y, 20, 20);}
  12. 12. ‣ofPoint testApp::interpolateByPct(float _pct){! float pct = _pct;! ofPoint pos;! pos.x = (1-pct) * startPos.x + (pct) * endPos.x;! pos.y = (1-pct) * startPos.y + (pct) * endPos.y;! return pos;}void testApp::fadeToBlack() {! ofSetRectMode(OF_RECTMODE_CORNER);! ofSetColor(0, 0, 0, 10);! ofRect(0, 0, ofGetWidth(), ofGetHeight());}
  13. 13.
  14. 14. ‣‣‣‣‣‣‣
  15. 15. ‣#pragma once#include "ofMain.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();! void keyPressed (int key);! void keyReleased(int key);! void mouseMoved(int x, int y );! void mouseDragged(int x, int y, int button);! void mousePressed(int x, int y, int button);! void mouseReleased(int x, int y, int button);! void windowResized(int w, int h);! void dragEvent(ofDragInfo dragInfo);! void gotMessage(ofMessage msg);!! float pct;! float shaper;! ofPoint currentPos, startPos, endPos;! ofPoint interpolateByPct(float pct, float shaper);! void fadeToBlack();};
  16. 16. ‣#include "testApp.h"void testApp::setup(){! ofSetBackgroundAuto(false);! ofSetVerticalSync(true);! ofEnableAlphaBlending();! ofSetFrameRate(60);! ofBackground(0, 0, 0);! startPos.set(10, 400);! endPos.set(1000, 300);! pct = 0.0;! shaper = 4.0;}void testApp::update(){! pct += 0.01f;! if (pct > 1) {! ! pct = 0;! }!! currentPos = interpolateByPct(pct, shaper);}
  17. 17. ‣void testApp::draw(){! fadeToBlack();! ofSetRectMode(OF_RECTMODE_CENTER);! ofSetColor(31, 127, 255);! ofRect(currentPos.x, currentPos.y, 20, 20);}ofPoint testApp::interpolateByPct(float _pct, float _shaper){! float pct = powf(_pct, _shaper);! ofPoint pos;! pos.x = (1-pct) * startPos.x + (pct) * endPos.x;! pos.y = (1-pct) * startPos.y + (pct) * endPos.y;! return pos;}void testApp::fadeToBlack() {! ofSetRectMode(OF_RECTMODE_CORNER);! ofSetColor(0, 0, 0, 10);! ofRect(0, 0, ofGetWidth(), ofGetHeight());}
  18. 18.
  19. 19.
  20. 20. ‣‣ ‣ ‣‣ ‣ ‣
  21. 21. ‣‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣‣‣
  22. 22. ‣‣ ‣ ‣ ‣ ‣ ‣
  23. 23.
  24. 24. ‣000100 IDENTIFICATION DIVISION.000200 PROGRAM-ID. HELLOWORLD.000300 DATE-WRITTEN. 02/05/96 21:04.000400*AUTHOR BRIAN COLLINS000500 ENVIRONMENT DIVISION.000600 CONFIGURATION SECTION.000700 SOURCE-COMPUTER. RM-COBOL.000800 OBJECT-COMPUTER. RM-COBOL.000900001000 DATA DIVISION.001100 FILE SECTION.001200100000 PROCEDURE DIVISION.100100100200 MAIN-LOGIC SECTION.100300 BEGIN.100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS.100500 DISPLAY "HELLO, WORLD." LINE 15 POSITION 10.100600 STOP RUN.100700 MAIN-LOGIC-EXIT.100800 EXIT.
  25. 25. ‣‣ ‣ ‣ ‣
  26. 26.
  27. 27. ‣ ‣ ‣ ‣ ‣
  28. 28. ‣‣‣‣‣‣
  29. 29.
  30. 30. ‣ ‣ ‣ ‣ ‣ ‣
  31. 31. ‣‣‣
  32. 32. ‣‣
  33. 33.
  34. 34. To invent programs, you need to be able to capture abstractions and ex design. It’s the job of a programming language to help you do this. The process of invention and design by letting you encode abstractions tha It should let you make your ideas concrete in the code you write. Surf the architecture of your program.‣‣ All programming languages provide devices that help express abstrac are ways of grouping implementation details, hiding them, and giving‣ a common interface—much as a mechanical object separates its interfa illustrated in “Interface and Implementation” .‣ Figure 2-1 Inte rfa ce a nd Im ple m e nta tion interface implementation 11 10 9 8 7 6
  35. 35. ‣‣‣
  36. 36. ‣‣‣‣ getName() getName()
  37. 37. ‣ ‣ ‣
  38. 38. ‣‣‣
  39. 39. ‣‣
  40. 40.
  41. 41. ‣‣‣ ‣ ‣ ‣ ‣ ‣‣ ‣ ‣
  42. 42. ‣‣‣ ‣‣ ‣‣ ‣
  43. 43. ‣ ‣ ‣‣‣
  44. 44. ‣‣
  45. 45.
  46. 46.
  47. 47.
  48. 48.
  49. 49.
  50. 50. ‣‣
  51. 51. ‣#pragma once#include "ofMain.h"#include "Rectangle.h"class testApp : public ofBaseApp{!public:! void setup();! void update();! void draw();!! void keyPressed (int key);! void keyReleased(int key);! void mouseMoved(int x, int y );! void mouseDragged(int x, int y, int button);! void mousePressed(int x, int y, int button);! void mouseReleased(int x, int y, int button);! void windowResized(int w, int h);! void dragEvent(ofDragInfo dragInfo);! void gotMessage(ofMessage msg);!! Rectangle myRectangle;};
  52. 52. ‣#include "testApp.h"void testApp::setup(){! ofSetBackgroundAuto(false);! ofSetVerticalSync(true);! ofEnableAlphaBlending();! ofSetFrameRate(60);! ofBackground(0, 0, 0);!! myRectangle.pos.x = ofGetWidth()/2;! myRectangle.pos.y = ofGetHeight()/2;}void testApp::update(){}void testApp::draw(){! myRectangle.draw();}
  53. 53. ‣#pragma once#include "ofMain.h"class Rectangle {public:! void draw();! ofPoint pos;};
  54. 54. ‣#include "rectangle.h"void Rectangle::draw() {! ofFill();! ofSetRectMode(OF_RECTMODE_CENTER);! ofSetColor(31,127,255);! ofRect(pos.x, pos.y, 20,20);}
  55. 55.
  56. 56. ‣‣ ‣‣ ‣ ‣ ‣ ‣ ‣

×