Successfully reported this slideshow.
Your SlideShare is downloading. ×

openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 44 Ad
Advertisement

More Related Content

Similar to openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII (20)

Advertisement

More from Atsushi Tadokoro (20)

Recently uploaded (20)

Advertisement

openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII

  1. 1. ‣ ‣ ‣ ‣
  2. 2.
  3. 3.
  4. 4. ‣ #include "testApp.h" void testApp::setup(){ ofBackground(255, 255, 255); ofEnableAlphaBlending(); ofSetCircleResolution(32); } void testApp::update(){ } void testApp::draw(){ ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ofSetColor(255, 63, 63, 200); ofCircle(0, -150, 200); ofRotateZ(120); ofSetColor(63, 63, 255, 200); ofCircle(0, -150, 200); ofRotateZ(120); ofSetColor(63, 255, 63, 200); ofCircle(0, -150, 200); }
  5. 5.
  6. 6. ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣
  7. 7. ‣ ‣ ‣ ‣
  8. 8. ‣ ‣ ‣ ‣ ‣ ‣ ‣
  9. 9. ‣ #include "testApp.h" void testApp::setup(){ ofBackground(255, 255, 255); ofEnableAlphaBlending(); ofSetCircleResolution(128); ofSetBackgroundAuto(false); ofSetFrameRate(60); } void testApp::update(){ } void testApp::draw(){ ofSetColor(63, 63, 255, 127); ofCircle(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()), 20); }
  10. 10.
  11. 11. ‣ ‣ ‣ ‣
  12. 12. ‣ ‣ ‣
  13. 13. ‣ ‣ ‣ ‣
  14. 14. ‣ #include "testApp.h" float radius; void testApp::setup(){ ofBackground(255, 255, 255); ofEnableAlphaBlending(); ofSetCircleResolution(128); ofSetFrameRate(60); } void testApp::update(){ radius = sin(2.0 * ofGetElapsedTimef()) * 100.0f + 200; } void testApp::draw(){ ofSetColor(63, 63, 255); ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ofCircle(0, 0, radius); }
  15. 15.
  16. 16. ‣ ‣ ‣ ‣ ‣ ‣ ‣
  17. 17. ‣ #include "testApp.h" float bg, fg; void testApp::setup(){ ofBackground(255, 255, 255); ofSetCircleResolution(128); ofSetFrameRate(60); ofSetVerticalSync(true); } void testApp::update(){ bg = sin(ofGetElapsedTimef() * 2.0) * 127 + 127; fg = sin(ofGetElapsedTimef() * 3.0) * 127 + 127; } void testApp::draw(){ ofBackground(bg, bg, bg); ofSetColor(fg, fg, fg); ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ofCircle(0, 0, 300); }
  18. 18.
  19. 19. ‣ ‣
  20. 20. ‣ if ( 条件式】) { 条件式が正しい時の処理 (真文)】 } else { 条件式が正しくない時の処理 (偽文)】 }
  21. 21. ‣ ‣ ‣ ‣ ‣ if ( 中心からの距離 < 200】) { 青く塗る】 } else { 赤く塗る】 }
  22. 22. ‣ ‣ ‣ ‣ ‣
  23. 23. ‣ #include "testApp.h" ofPoint pos; void testApp::setup(){ ofBackground(255, 255, 255); ofSetCircleResolution(128); ofSetFrameRate(60); ofSetVerticalSync(true); ofSetBackgroundAuto(false); ofEnableAlphaBlending(); } void testApp::update(){ pos.x = ofRandom(ofGetWidth()); pos.y = ofRandom(ofGetHeight()); } void testApp::draw(){ if (ofDist(ofGetWidth()/2, ofGetHeight()/2, pos.x, pos.y) < 200) { ofSetColor(255, 63, 63, 127); } else { ofSetColor(63, 63, 255, 127); } ofCircle(pos.x, pos.y, 10); }
  24. 24.
  25. 25.
  26. 26. ‣ ‣ ‣
  27. 27. ‣ for ( 初期化】; ループの継続条件】; カウンタ変数の更新】;) { くりかえし実行する処理】 } ‣ for (int i = 0; i < 100; i++) { くりかえし実行する処理】 }
  28. 28. ‣ ‣ ‣ ‣
  29. 29. ‣ #include "testApp.h" #define NUM 120 ofPoint pos; void testApp::setup(){ ofBackground(0, 0, 0); ofSetFrameRate(60); ofSetVerticalSync(true); } void testApp::update(){ } void testApp::draw(){ ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ofSetColor(63, 63, 255); for (int i = 0; i < NUM; i++) { ofRotateZ(360.f/NUM); float pos = sin(ofGetElapsedTimef()) * ofGetHeight()/2.5; ofCircle(pos, 0, 5); } }
  30. 30.
  31. 31. ‣ ‣ ‣
  32. 32. ‣ #include "testApp.h" #define NUM 120 ofPoint pos; void testApp::setup(){ ofBackground(0, 0, 0); ofSetFrameRate(60); ofSetVerticalSync(true); } void testApp::update(){ } void testApp::draw(){ ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); ofSetColor(63, 63, 255); for (int i = 0; i < NUM; i++) { ofRotateZ(360.f / NUM); float pos = sin(ofGetElapsedTimef() * ((float)(i) / NUM)) * ofGetHeight() / 2.5; ofCircle(pos, 0, 5); } }
  33. 33.
  34. 34. ‣ ‣ ‣
  35. 35. ‣ #include "testApp.h" #define NUM 1200 ofPoint pos; void testApp::setup(){ ofBackground(0, 0, 0); ofSetFrameRate(60); ofSetVerticalSync(true); } void testApp::update(){ } void testApp::draw(){ ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); ofSetColor(63, 63, 255); for (int i = 0; i < NUM; i++) { ofRotateZ(360.f / NUM); float pos = sin(ofGetElapsedTimef() * ((float)(i) / NUM)) * ofGetHeight() / 2.5; ofCircle(pos, 0, 2); } }
  36. 36.
  37. 37. ‣ #include "testApp.h" #define NUM 12000 ofPoint pos; void testApp::setup(){ ofBackground(0, 0, 0); ofSetFrameRate(60); ofSetVerticalSync(true); } void testApp::update(){ } void testApp::draw(){ ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); ofSetColor(63, 63, 255); for (int i = 0; i < NUM; i++) { ofRotateZ(360.f / NUM); float pos = sin((ofGetElapsedTimef()+30000.f) * ((float)(i) / NUM / 10.0)) * ofGetHeight() / 2.5; ofCircle(pos, 0, 1); } }
  38. 38.
  39. 39. ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣

×