More Related Content
More from Atsushi Tadokoro
More from Atsushi Tadokoro (20)
Sbaw090526
- 11. #include quot;testApp.hquot;
//--------------------------------------------------------------
void testApp::setup(){
ofSetCircleResolution(128);
ofBackground(0, 0, 0);
ofSetColor(31,63,255);
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
ofCircle(mouseX, mouseY, 80);
}
//--------------------------------------------------------------
void testApp::exit(){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
- 12. //--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
ofSetColor(255,63,31);
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
ofBackground(255, 255, 255);
}
//--------------------------------------------------------------
void testApp::mouseReleased(){
ofBackground(0, 0, 0);
ofSetColor(31,63,255);
}
...( )...
- 16. #pragma once
#include quot;ofMain.hquot;
#include quot;ofxAccelerometer.hquot;
#include quot;ofxMultiTouch.hquot;
#define NUM 100
class testApp : public ofSimpleApp, public ofxMultiTouchListener {
public:
void setup();
void update();
void draw();
void exit();
...( )...
int ballCount; //
ofPoint pressedPos; //
ofPoint pos[NUM], speed[NUM]; //
ofColor col[NUM]; //
};
- 17. #include quot;testApp.hquot;
//--------------------------------------------------------------
void testApp::setup(){
ofEnableAlphaBlending();
ballCount = 0;
pressedPos.x = 0;
pressedPos.y = 0;
}
//--------------------------------------------------------------
void testApp::update(){
for(int i = 0; i < ballCount; i++){
pos[i].x += speed[i].x;
pos[i].y += speed[i].y;
if(pos[i].x<0 || pos[i].x>ofGetWidth()){
speed[i].x *= -1;
}
if(pos[i].y<0 || pos[i].y>ofGetHeight()){
speed[i].y *= -1;
}
}
}
//--------------------------------------------------------------
void testApp::draw(){
for(int i = 0; i < ballCount; i++){
- 18. ofSetColor(col[i].r, col[i].g, col[i].b, 127);
ofCircle(pos[i].x, pos[i].y, 20);
}
}
//--------------------------------------------------------------
void testApp::exit(){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
pos[ballCount-1].x = x;
pos[ballCount-1].y = y;
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
ballCount++;
if(ballCount > NUM){
ballCount = 1;
}
pos[ballCount-1].x = x;
pos[ballCount-1].y = y;
speed[ballCount-1].x = 0;
speed[ballCount-1].y = 0;
- 19. col[ballCount-1].r = ofRandom(0, 255);
col[ballCount-1].g = ofRandom(0, 255);
col[ballCount-1].b = ofRandom(0, 255);
pressedPos.x = x;
pressedPos.y = y;
}
//--------------------------------------------------------------
void testApp::mouseReleased(){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
speed[ballCount-1].x = (x - pressedPos.x) * 0.1;
speed[ballCount-1].y = (y - pressedPos.y) * 0.1;
}
...( )...
- 22. 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
- 23. #pragma once
#include quot;ofMain.hquot;
#include quot;ofxAccelerometer.hquot;
#include quot;ofxMultiTouch.hquot;
#define LENGTH 50
class testApp : public ofSimpleApp, public ofxMultiTouchListener {
public:
void setup();
void update();
void draw();
void exit();
...( )...
ofPoint pos[LENGTH];
};
- 27. #pragma once
#include quot;ofMain.hquot;
#include quot;ofxAccelerometer.hquot;
#include quot;ofxMultiTouch.hquot;
#define NUM 8 //
#define DELAY 20 //
#define LENGTH NUM*DELAY //
#define MAX_SIZE 400 //
class testApp : public ofSimpleApp, public ofxMultiTouchListener {
public:
void setup();
void update();
void draw();
...( )...
//
ofPoint pos[LENGTH];
};
- 36. #pragma once
#include quot;ofMain.hquot;
#include quot;ofxAccelerometer.hquot;
#include quot;ofxMultiTouch.hquot;
class testApp : public ofSimpleApp, public ofxMultiTouchListener {
public:
void setup();
void update();
void draw();
void exit();
...( )...
ofPoint pos;
float angle, radius, speed;
};
- 40. #pragma once
#include quot;ofMain.hquot;
#include quot;ofxAccelerometer.hquot;
#include quot;ofxMultiTouch.hquot;
#define NUM 256
class testApp : public ofSimpleApp, public ofxMultiTouchListener {
public:
void setup();
void update();
void draw();
void exit();
...( )...
float angle[NUM];
float radius, maxSpeed, maxSize;
};
- 41. #include quot;testApp.hquot;
//--------------------------------------------------------------
void testApp::setup(){
ofNoFill();
ofEnableAlphaBlending();
ofSetCircleResolution(256);
ofSetColor(0, 0, 255, 127);
radius = 80;
maxSpeed = 0.25;
maxSize = 80;
for(int i = 0; i < NUM; i++){
angle[i] = 0;
}
}
//--------------------------------------------------------------
void testApp::update(){
for(int i = 0; i < NUM; i++){
float thisSpeed = (maxSpeed / NUM) * i;
pos[i].x = ofGetWidth()/2 + (radius * sin(angle[i] * PI / 180.0));
pos[i].y = ofGetHeight()/2 + (radius * cos(angle[i] * PI / 180.0));
angle[i] += thisSpeed;
}
}
- 42. //--------------------------------------------------------------
void testApp::draw(){
for(int i = 0; i < NUM; i++){
float thisSize = (maxSize / NUM) * i;
ofCircle(pos[i].x, pos[i].y, thisSize);
}
}
//--------------------------------------------------------------
void testApp::exit(){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
for(int i = 0; i < NUM; i++){
angle[i] += i * y / 100.0;
}
}
...( )...
- 47. #pragma once
#include quot;ofMain.hquot;
#include quot;ofxAccelerometer.hquot;
#include quot;ofxMultiTouch.hquot;
#define NUM 5096
#define TOWPI PI * 2.0
class testApp : public ofSimpleApp, public ofxMultiTouchListener {
public:
void setup();
void update();
void draw();
void exit();
...( )...
ofPoint pos[NUM];
float counter, speed;
};
- 49. //X,Y
pos[i].x = ofGetWidth()/2.0 + cos(theta)*rd;
pos[i].y = ofGetHeight()/2.0 + sin(theta)*rd;
}
//
counter += speed;
}
//--------------------------------------------------------------
void testApp::draw(){
for(int i = 0; i < NUM; i++){
ofCircle(pos[i].x, pos[i].y, 2);
}
}
...( )...
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
counter += y / 100.0;
}
...( )...