-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
124 lines (85 loc) · 3.15 KB
/
index.html
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<html>
<head>
<meta http-equiv="refresh" content="30">
<script src="/libs/snap.svg.js"></script>
</head>
<body bgcolor="black" text="white">
<h1 style="text-align: center">Heja Hejare!</h1>
<svg id="svg" width="500" height="400"> </svg>
<img src="img/landscape-bw.jpg" style="width: 100%" />
<script>
var s = Snap("#svg");
// Lets create big circle in the middle:
var flowerStalk = s.path("M200 200 q 0 -100 -40 -120");
flowerStalk.attr({
strokeWidth: 10,
stroke: "#fff",
strokeLinecap: "round"
});
// Flower head
class Leaf {
constructor(s, direction) {
this.d = (direction === "left") ? -1 : 1;
this.leaf = s.path("M200 150 c" + 100*this.d + ",-40 " + this.d*100 + ",40 0,0")
.attr({stroke: "#fff", fill: "transparent", strokeWidth: 4})
.transform("r-10");
}
startAnimation() {
this.leaf.animate({d: "M200 150 c" + 100*this.d + ",-60 " + this.d*100 + ",20 0,0"},
3000,
mina.easeinout,
this.reverseAnimation.bind(this));
}
reverseAnimation() {
this.leaf.animate({d: "M200 150 c" + 100*this.d + ",-40 " + this.d*100 + ",40 0,0"},
3000,
mina.bounce,
this.startAnimation.bind(this));
}
}
class Head {
constructor(s) {
this.head = s.group(s.circle(24, 24, 25).attr({fill: "#fff"}),
s.circle(19, 0, 24).attr({fill: "#fff"}),
s.circle(0, 14, 24).attr({fill: "#fff"}),
s.circle(38, 14, 24).attr({fill: "#fff"}),
s.circle(7, 36.5, 24).attr({fill: "#fff"}),
s.circle(31, 36.5, 24).attr({fill: "#fff"}),
s.circle(22, 22, 8).attr({fill: "#000"}));
this.head.transform("T125 55");
}
startAnimation() {
this.head.animate({transform: this.head.transform() + "t100 0 r360"},
5000,
mina.easeinout,
this.reverseAnimation.bind(this));
}
reverseAnimation() {
this.head.animate({transform: this.head.transform() + "t-100 0 r360"},
5000,
mina.easeinout,
this.startAnimation.bind(this));
}
}
let l = new Leaf(s, "left");
l.startAnimation();
let l2 = new Leaf(s);
l2.startAnimation();
function reverseStalkAnimation() {
flowerStalk.animate({d: "M200 200 q 0 -100 -40 -120"},
5000,
mina.easeinout,
startStalkAnimation);
};
function startStalkAnimation() {
flowerStalk.animate({d: "M200 200 q 0 -100 40 -120"},
5000,
mina.easeinout,
reverseStalkAnimation);
};
startStalkAnimation();
let h = new Head(s);
h.startAnimation();
</script>
</body>
</html>