More Related Content
More from Atsushi Tadokoro
More from Atsushi Tadokoro (20)
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
- 4. ‣
‣
setup( )
update( )
draw( )
- 5. ‣
‣
setup( )
update( )
draw( )
- 6. ‣
‣
setup( )
update( )
draw( )
- 7. ‣
‣
setup( )
update( )
draw( )
- 8. ‣
‣
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);! //
}
- 17. ‣
‣
ofGetWidth()
0
ofGetHeight()
- 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);
}
- 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);
}
- 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(); //
}
- 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(); //
}
- 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();
}