-
Notifications
You must be signed in to change notification settings - Fork 295
/
Presets.kt
105 lines (98 loc) 路 3.72 KB
/
Presets.kt
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
package nl.dionsegijn.samples.shared
import android.graphics.drawable.Drawable
import nl.dionsegijn.konfetti.core.Angle
import nl.dionsegijn.konfetti.core.Party
import nl.dionsegijn.konfetti.core.Position
import nl.dionsegijn.konfetti.core.Rotation
import nl.dionsegijn.konfetti.core.Spread
import nl.dionsegijn.konfetti.core.emitter.Emitter
import nl.dionsegijn.konfetti.core.models.Shape
import nl.dionsegijn.konfetti.core.models.Size
import java.util.concurrent.TimeUnit
class Presets {
companion object {
fun festive(drawable: Shape.DrawableShape? = null): List<Party> {
val party = Party(
speed = 30f,
maxSpeed = 50f,
damping = 0.9f,
angle = Angle.TOP,
spread = 45,
size = listOf(Size.SMALL, Size.LARGE, Size.LARGE),
shapes = listOf(Shape.Square, Shape.Circle, drawable).filterNotNull(),
timeToLive = 3000L,
rotation = Rotation(),
colors = listOf(0xfce18a, 0xff726d, 0xf4306d, 0xb48def),
emitter = Emitter(duration = 100, TimeUnit.MILLISECONDS).max(30),
position = Position.Relative(0.5, 1.0)
)
return listOf(
party,
party.copy(
speed = 55f,
maxSpeed = 65f,
spread = 10,
emitter = Emitter(duration = 100, TimeUnit.MILLISECONDS).max(10),
),
party.copy(
speed = 50f,
maxSpeed = 60f,
spread = 120,
emitter = Emitter(duration = 100, TimeUnit.MILLISECONDS).max(40),
),
party.copy(
speed = 65f,
maxSpeed = 80f,
spread = 10,
emitter = Emitter(duration = 100, TimeUnit.MILLISECONDS).max(10),
)
)
}
fun explode(): List<Party> {
return listOf(
Party(
speed = 0f,
maxSpeed = 30f,
damping = 0.9f,
spread = 360,
colors = listOf(0xfce18a, 0xff726d, 0xf4306d, 0xb48def),
emitter = Emitter(duration = 100, TimeUnit.MILLISECONDS).max(100),
position = Position.Relative(0.5, 0.3)
)
)
}
fun parade(): List<Party> {
val party = Party(
speed = 10f,
maxSpeed = 30f,
damping = 0.9f,
angle = Angle.RIGHT - 45,
spread = Spread.SMALL,
colors = listOf(0xfce18a, 0xff726d, 0xf4306d, 0xb48def),
emitter = Emitter(duration = 5, TimeUnit.SECONDS).perSecond(30),
position = Position.Relative(0.0, 0.5)
)
return listOf(
party,
party.copy(
angle = party.angle - 90, // flip angle from right to left
position = Position.Relative(1.0, 0.5)
),
)
}
fun rain(): List<Party> {
return listOf(
Party(
speed = 0f,
maxSpeed = 15f,
damping = 0.9f,
angle = Angle.BOTTOM,
spread = Spread.ROUND,
colors = listOf(0xfce18a, 0xff726d, 0xf4306d, 0xb48def),
emitter = Emitter(duration = 5, TimeUnit.SECONDS).perSecond(100),
position = Position.Relative(0.0, 0.0).between(Position.Relative(1.0, 0.0))
)
)
}
}
}