-
Notifications
You must be signed in to change notification settings - Fork 0
/
rects.js
97 lines (90 loc) · 1.93 KB
/
rects.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
global Renderium Vector layer
*/
class Rect extends Renderium.Component {
constructor (options) {
super()
this.position = options.position
this.color = options.color
this.fillColor = options.fillColor
this.width = options.width
this.height = options.height
this.strokeWidth = options.strokeWidth
this.opacity = options.opacity
this.lineDash = options.lineDash
this._shouldRedraw = true
}
shouldRedraw () {
return this._shouldRedraw
}
draw (layer) {
layer.drawRect({
position: this.position,
color: this.color,
fillColor: this.fillColor,
width: this.width,
height: this.height,
strokeWidth: this.strokeWidth,
opacity: this.opacity,
lineDash: this.lineDash
})
this._shouldRedraw = false
}
}
layer.addComponents([
new Rect({
position: new Vector(50, 50),
color: Renderium.colors.RED,
fillColor: void 0,
width: 50,
height: 50,
strokeWidth: 1,
opacity: 1,
lineDash: []
}),
new Rect({
position: new Vector(150, 50),
color: void 0,
fillColor: layer.createGradient({
start: new Vector(0, 50),
end: new Vector(0, 100),
from: Renderium.colors.LIGHT_BLUE,
to: Renderium.colors.INDIGO
}),
width: 50,
height: 50,
strokeWidth: 2,
opacity: 1,
lineDash: []
}),
new Rect({
position: new Vector(250, 25),
color: Renderium.colors.YELLOW,
fillColor: void 0,
width: 100,
height: 100,
strokeWidth: 2,
opacity: 1,
lineDash: []
}),
new Rect({
position: new Vector(400, 50),
color: Renderium.colors.GREEN,
fillColor: void 0,
width: 50,
height: 50,
strokeWidth: 5,
opacity: 0.5,
lineDash: []
}),
new Rect({
position: new Vector(500, 50),
color: Renderium.colors.PURPLE,
fillColor: void 0,
width: 50,
height: 50,
strokeWidth: 5,
opacity: 1,
lineDash: [10, 5]
})
])