-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixProcessing.h
More file actions
72 lines (51 loc) · 1.11 KB
/
Copy pathMatrixProcessing.h
File metadata and controls
72 lines (51 loc) · 1.11 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef RENDER_MATRIX_PROCESSING
#define RENDER_MATRIX_PROCESSING
#include "WindCanvas.h"
#include <memory>
#include <vector>
const int g_StepTime = 18;
class MatrixProcessing
{
private:
std::shared_ptr<Font> neo_font;
std::shared_ptr<WindCanvas> canvas;
int x_start = 10, y_start = 10;
int latest_x = 0, latest_y = 0;
struct Trail {
int x = 0, y = 0;
float speed = 0;
int trail_len_max = 0, trial_len = 0;
double timer = 0;
double stepTime = 0.1;
void Step(double delta)
{
double stepTime = g_StepTime / (speed > 0 ? speed : 1.0);
timer += delta;
while (timer >= stepTime) {
y += g_StepTime;
if (trial_len < trail_len_max)
trial_len++;
else
trial_len = trail_len_max;
timer -= stepTime;
}
}
void clear()
{
x = y = trail_len_max = trial_len = 0;
speed = 0;
}
bool CanBeDrawn()
{
return x != 0;
}
};
std::vector<Trail> trails = {};
public:
MatrixProcessing(std::shared_ptr<WindCanvas> canvas);
void Draw(double delta);
private:
std::string GetRandomChar();
void ProcessTrails(double delta);
};
#endif // !RENDER_MATRIX_PROCESSINGS