-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcucumber.js
35 lines (30 loc) · 976 Bytes
/
cucumber.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
module.exports = class Cucumber {
static create(x, y) {
return new Cucumber(x, y);
}
constructor(x, y) {
this.x = x;
this.y = y;
this.width = Cucumber._getRandomInt(35, 55);
this.animationDuration = Cucumber._getRandomInt(25, 50);
this.rotation = Cucumber._getRandomInt(0, 360);
this.bezier = Cucumber._getBezier();
}
static _getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
static _getBezier() {
const bez = [
Cucumber._getRandomFloat(0.2, 0.8),
Cucumber._getRandomFloat(0.2, 0.5),
Cucumber._getRandomFloat(0.2, 0.5),
Cucumber._getRandomFloat(0.2, 0.5)
].join(', ');
return 'cubic-bezier(' + bez + ')';
}
static _getRandomFloat(min, max) {
return (Math.random() * (max - min)) + min;
}
};