-
Notifications
You must be signed in to change notification settings - Fork 2
/
Pattern.cpp
51 lines (46 loc) · 1.39 KB
/
Pattern.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "Pattern.h"
void Pattern::setup(float x, float width){
counter = 0;
colX = x;
colW = width;
patInfo.clear();
}
void Pattern::update(){
counter++;
if(counter==120) counter=0;
for(int i=0;i<patInfo.size();i++){
if(counter==patInfo[i].time){
patInfo[i].playing=true;
//printf("hit %i ,",counter);
}else{
patInfo[i].playing=false;
}
}
}
void Pattern::draw(){
for(int i=0;i<patInfo.size();i++){
float timeX = ofMap(patInfo[i].time,0,119,colX,colX+colW);
float radius;
if(patInfo[i].playing){
ofSetColor(255,200);
radius = 200;
}else{
ofSetColor(127);
radius = 20;
}
ofFill();
ofCircle(patInfo[i].x, patInfo[i].y,radius);
ofNoFill();
ofRect(timeX-radius/2, ofGetHeight()/2-radius, radius,radius*2);
//ofLine(timeX-radius, ofGetHeight()/2, timeX+radius, ofGetHeight()/2);
//ofLine(timeX, ofGetHeight()/2-radius, timeX, ofGetHeight()/2+radius);
ofLine(patInfo[i].x, patInfo[i].y, timeX, ofGetHeight()/2);
}
}
void Pattern::add(int myX,int myY,int myTime, float myColX){
patInfo.push_back(touchInfo());
patInfo[patInfo.size()-1].x=myX;
patInfo[patInfo.size()-1].y=myY;
patInfo[patInfo.size()-1].time=myTime;
patInfo[patInfo.size()-1].playing=false;
}