-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathTestEasing.dart
93 lines (79 loc) · 2.27 KB
/
TestEasing.dart
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
//Sample Code: Test Animation 2
import 'dart:html';
import 'dart:math';
import 'package:rikulo_ui/view.dart';
import 'package:rikulo_ui/event.dart';
import 'package:rikulo_ui/effect.dart';
View createCube(int size, String txt) {
View v = new View();
v.width = size;
v.height = size;
v.style.border = "2px solid #3D4C99";
v.style.borderRadius = "10px";
v.style.backgroundColor = "#5C73E5";
v.style.userSelect = "none";
v.style.zIndex = "10";
TextView txtv = new TextView(txt);
txtv.width = v.width - 4;
txtv.style.lineHeight = "${v.height - 4}px";
txtv.style.textAlign = "center";
txtv.style.color = "#EEEEEE";
txtv.style.fontFamily = "Arial";
txtv.style.fontWeight = "bold";
txtv.style.userSelect = "none";
v.addChild(txtv);
return v;
}
/*MotionAction _action(Element elem, Point center) =>
(num x, MotionState state) {
elem.style.left = CssUtil.px(center.x + 50 * sin(x * 2 * PI));
elem.style.top = CssUtil.px(center.y - 50 * cos(x * 2 * PI));
};*/
void blue(View v) {
v.style.borderColor = "#3D4C99";
v.style.backgroundColor = "#5C73E5";
}
void green(View v) {
v.style.borderColor = "#3D993D";
v.style.backgroundColor = "#5CE55C";
}
void main() {
final View mainView = new View()..addToDocument();
List<Point> centers =
[new Point(100, 100), new Point(400, 100), new Point(100, 400)];
// List<int> repeats = [1, 3, -1];
List<View> cubes = [];
for (int i = 0; i < 3; i++) {
View c = createCube(50, "Cube $i");
c.left = centers[i].x;
c.top = centers[i].y - 50;
cubes.add(c);
mainView.addChild(c);
}
List<EasingMotion> motions = [null, null, null];
// List<Button> stops = [];
for (int i = 0; i < 3; i++) {
Button b = new Button("Stop $i");
b.left = 350;
b.top = 350 + 50 * i;
mainView.addChild(b);
b.on.click.listen((ViewEvent event) {
EasingMotion m = motions[i];
if (m != null)
m.stop();
blue(cubes[i]);
});
}
for (int i = 0; i < 3; i++) {
cubes[i].on.click.listen((ViewEvent event) {
return;
/*
green(cubes[i]);
motions[i] = new EasingMotion(_action(cubes[i].node, centers[i]),
end: (MotionState state) {
blue(cubes[i]);
}, period: 1000, repeat: repeats[i])..run();
*/
});
}
}