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
use ;
/// A group of things.
///
/// The inner of a group is a [`Vec`], it has the ownership of the elements.
///
/// [`Group<T>`] implements [`FromIterator`], [`IntoIterator<Item = T>`], so it can be
/// collected from an iterator, and also can be used for `impl IntoIterator<Item = T>`:
///
/// ```rust
/// let group = (0..9).map(|i| Square(100.0 * i as f32).build()).collect::<Group<_>>();
/// let group = group.into_iter().map(|item| timeline.insert(item)).collect::<Group<_>>();
/// ```
///
/// For a group of items, you can use [`Group::lagged_anim`] to create animation on every item:
///
/// ```rust
/// timeline.play(group.lagged_anim(0.2, |item| {
/// item.write()
/// }).with_duration(5.0).apply());
/// ```
///
/// For some animation (like [`crate::animation::transform::Transform`]), it may support
/// creating directly for item's slice. This often happens when some operation on the group
/// is not equivalent to applying the same operation on each item (like [`crate::components::Transformable::scale`]).
///
/// For example, if logo is a `Group<VItem>` with six elements:
///
/// ```rust
/// let scale = [
/// vec3(scale, 1.0, 1.0),
/// vec3(scale, scale, 1.0),
/// vec3(scale, scale, 1.0),
/// ];
/// let anchor = [
/// Anchor::edge(-1, 0, 0),
/// Anchor::edge(1, 1, 0),
/// Anchor::edge(1, -1, 0),
/// ];
/// logo.chunks_mut(2)
/// .zip(scale.into_iter().zip(anchor))
/// .for_each(|(chunk, (scale, anchor))| {
/// timeline.play(
/// chunk
/// .transform(|data| {
/// data.scale_by_anchor(scale, anchor)
/// .scale_by_anchor(vec3(0.9, 0.9, 1.0), Anchor::origin())
/// .shift(vec3(0.0, frame_size.y / 9.0, 0.0));
/// })
/// .with_rate_func(smooth)
/// .apply(),
/// );
/// });
/// ```
///
/// [`AsRef<[T]>`](AsRef) and [`AsMut<[T]>`](AsMut) are implemented for `Group<T>`.
///
///
;