More Related Content
More from Atsushi Tadokoro (20)
openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII
- 7. ‣
#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);
}
- 12. ‣
#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);
}
- 17. ‣
#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);
}
- 20. ‣
#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);
}
- 24. ‣
if ( 条件式】) {
条件式が正しい時の処理 (真文)】
} else {
条件式が正しくない時の処理 (偽文)】
}
- 25. ‣
‣
‣
‣
‣
if ( 中心からの距離 < 200】) {
青く塗る】
} else {
赤く塗る】
}
- 27. ‣
#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);
}
- 32. ‣
for ( 初期化】; ループの継続条件】; カウンタ変数の更新】;) {
くりかえし実行する処理】
}
‣
for (int i = 0; i < 100; i++) {
くりかえし実行する処理】
}
- 34. ‣
#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);
}
}
- 37. ‣
#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);
}
}
- 40. ‣
#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);
}
}
- 42. ‣
#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);
}
}