-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursor.cpp
53 lines (36 loc) · 990 Bytes
/
cursor.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
52
53
//
// cursor.cpp
// First_Astral_Sketch_Open_Frameworks
//
// Created by Timothy J on 29/05/14.
//
//
#include "cursor.h"
void Cursor::setup(ofFbo _fbo, ofColor _col){
fbo = _fbo;
col = _col;
}
void Cursor::update(float x, float y){
//currentX = 1;
static float x0 = 0;
static float y0 = 0;
const float dt = (1.0 / 5);
const double RC = 0.3;
const double alpha = dt / (RC + dt);
//ofVec2f smoothed;
position.x = (alpha * x) + (1.0 - alpha) * x0;
position.y = (alpha * y) + (1.0 - alpha) * y0;
//If some relationship between the acceleration and the previous values,
//output some OSC. this should be if there is significant change ?
//self.hooploop.updated = true;
x0 = position.x;
y0 = position.y;
}
void Cursor::draw(){
fbo.begin();
ofPushStyle();
ofSetColor(col);
ofCircle(position.x, position.y, 4);
ofPopStyle();
fbo.end();
}