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
|
define.class('$ui/view', function(require, view){
this.attributes = {
data: Config({type:Array, value:[]}),
}
this.clear = function() {
this.data = [];
}
this.hardrect = {
mesh: define.struct({
pos:vec2,
col:vec4
}).array(),
position: function(){
uv = mesh.pos.xy
pos = vec2(mesh.pos.x * view.layout.width, mesh.pos.y * view.layout.height)
var res = vec4(pos, 0, 1) * view.totalmatrix * view.viewmatrix
res.w -= 0.004
return res;
},
update: function() {
var mesh = this.mesh = this.mesh.struct.array();
var w = 0;
var thickness = 1 / this.view.data.length;
var color = this.view.fgcolor;
for (var i=0; i<this.view.data.length; i++) {
var x0 = w;
var x1 = w + thickness;
w += thickness;
var height = float(this.view.data[i]);
if (height > 0) {
mesh.pushQuad(
x0,1, color[0],color[1],color[2],1,
x1,1, color[0],color[1],color[2],1,
x0,1-height, color[0],color[1],color[2],1,
x1,1-height, color[0],color[1],color[2],1
)
}
}
},
color: function(){
return mesh.col;
}
}
})
|