-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGP_Stroke.hpp
55 lines (46 loc) · 1.18 KB
/
GP_Stroke.hpp
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
54
55
#ifndef STROKE_HPP
#define STROKE_HPP
//Convenient container for keeping track of a user stroke.
//Idea:
// points get submitted ->
// stroke chopped up into short segments ->
// short segments smoothed ->
// final stroke geometry generated (incrementally based on smoothed segments).
#include <Vector/Vector.hpp>
#include <vector>
#include <deque>
using std::vector;
using std::deque;
class Stroke {
public:
Stroke() {
clear();
}
virtual ~Stroke() { }
virtual void clear();
virtual void submit_point(Vector2f const &new_point);
vector< Vector2f > points;
unsigned int new_points; //basically a 'dirty' flag, for incremental computation.
bool dirty; //really a dirty flag (i.e. "re-do the entire thing")
};
class SmoothStroke : public Stroke {
public:
SmoothStroke() {
Step = 1;
smoothing_kernel.push_back( 0.25f );
smoothing_kernel.push_back( 0.50f );
smoothing_kernel.push_back( 0.25f );
clear();
}
virtual ~SmoothStroke() { }
virtual void clear();
virtual void submit_point(Vector2f const &new_point);
//options:
vector< float > smoothing_kernel;
float Step;
//dynamic stuff:
Vector2f last;
float along;
deque< Vector2f > smoothing_queue;
};
#endif //STROKE_HPP