-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeer.js
96 lines (79 loc) · 1.45 KB
/
beer.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
var paper = Snap('#beer');
// glass
const GLASS = {
fill: '#fff',
stroke: '#fcf9f9',
strokeWidth: 40
};
paper
.rect(50, 150, 300, 400, 10, 10)
.attr(GLASS);
// handle
const HANDLE = Object.assign({}, GLASS, {
fill: 'rgba(255, 255, 255, 0.0)'
});
paper
.rect(340, 250, 125, 200, 50, 50)
.attr(HANDLE);
// beer
const LIQUID = paper.gradient('l(0, 0, 1, 1)#EFC84A-#EFC84A');
const BEER = {
fill: LIQUID,
stroke: '#efc84a',
strokeWidth: 25
};
paper
.rect(75, 175, 250, 350, 10, 10)
.attr(BEER);
// head
const HEAD = { fill: '#fff' };
[
[50, 150, 30],
[75, 125, 40],
[100, 125, 30],
[125, 100, 40],
[150, 75, 30],
[175, 50, 20],
[200, 75, 30],
[225, 125, 50],
[275, 125, 30],
[300, 125, 25],
[325, 150, 45],
[275, 175, 30],
[225, 175, 40],
[175, 150, 60],
[100, 175, 30]
].forEach(coords => paper.circle(...coords).attr(HEAD));
// muck
const MUCK = {
fill: '#fff',
stroke: '#fff',
strokeWidth: 25
};
paper
.rect(200, 150, 1, 30, 10, 10)
.attr(MUCK)
.animate({
height: 300
}, 30000);
paper
.rect(250, 150, 1, 30, 10, 10)
.attr(MUCK)
.animate({
height: 250
}, 60000);
// bubbles
const BUBBLE = {
fill: 'rgba(255, 255, 255, 0.5)'
};
setInterval(() => {
let bubble = paper
.circle(80 + (~~(Math.random() * 220)), 525, 1)
.animate({
r: ~~(Math.random(10) * 10)
}, 2000)
.animate({
cy: 150
}, 5000, null, () => bubble.remove())
.attr(BUBBLE);
}, 1500);