-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathColorRectDrawer.xcsm
More file actions
51 lines (36 loc) · 1.24 KB
/
ColorRectDrawer.xcsm
File metadata and controls
51 lines (36 loc) · 1.24 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
//xlang Source, Name:ColorRectDrawer.xcsm
//Date: Sat Apr 00:39:17 2019
class ColorRectDrawer : EfficDrawer{
static const int WIDTH_COUNT = 30,
HWIGHT_COUNT = 20;
bool create() override {
return true;
}
void prepare() override {
//TODO:
}
void drawWave(QXPainter c, int w, int h) override {
short [] data = getEfficData();
int offset = getCurrentOffset(WIDTH_COUNT);
if (offset < 0){
return ;
}
c.setRenderHint(QXPainter.RenderHint.Antialiasing,true);
//linepaint.setAlpha(255);
double ocx = w / (WIDTH_COUNT - 1);
double ocy = h / (HWIGHT_COUNT - 1);
int cx = ocx - 2;
int cy = ocy - 2;
for (int x = 0; x < WIDTH_COUNT; x ++){
double rv = (1.f - Math.abs(data[offset + x] / 32768.f)) * h;
for (int y = 0; y < HWIGHT_COUNT; y++){
double t = h / HWIGHT_COUNT * y;
if (t > rv){
c.fillRect(x * ocx + 1, y * ocy + 1,cx,cy, 0xff000000 | (int)(Math.random() * 0x00ffffff), QXBrush.Style.SolidPattern);
}else{
c.fillRect(x * ocx + 1, y * ocy + 1,cx,cy, 0x20ffffff, QXBrush.Style.SolidPattern);
}
}
}
}
};