src
geometry
synchronization
video
···
10
10
}
11
11
12
12
pub fn from_radians(radians: f32) -> Self {
13
13
-
Self(radians * Self::TURN.0 / std::f32::consts::TAU)
13
13
+
Self::from_ratio(radians, std::f32::consts::TAU)
14
14
+
}
15
15
+
16
16
+
/// Creates an angle given an amount, and what a full turn is equal to
17
17
+
/// ```
18
18
+
/// use shapemaker::geometry::Angle;
19
19
+
///
20
20
+
/// assert_eq!(Angle::from_ratio(0.5, 1.0).degrees() as usize, 180);
21
21
+
/// assert_eq!(Angle::from_radians(std::f32::consts::TAU).degrees() as usize, 360);
22
22
+
/// ```
23
23
+
pub fn from_ratio(amount: f32, of: f32) -> Self {
24
24
+
Self(amount * Self::TURN.0 / of)
14
25
}
15
26
16
27
pub fn degrees(&self) -> f32 {
···
43
43
pub use video::{
44
44
Animation, AttachHooks, Scene, Timestamp, Video, animation, context,
45
45
};
46
46
+
pub use synchronization::audio::MusicalDurationUnit::*;
46
47
47
48
trait Toggleable {
48
49
fn toggle(&mut self);
···
77
77
})
78
78
}
79
79
80
80
+
fn assign_scene_to(
81
81
+
self,
82
82
+
marker_text: &'static str,
83
83
+
scene_name: &'static str,
84
84
+
) -> Self {
85
85
+
self.with_hook(Hook {
86
86
+
when: Box::new(move |_, context, _, _| {
87
87
+
context.marker() == marker_text
88
88
+
}),
89
89
+
render_function: Box::new(move |_, context| {
90
90
+
context.switch_scene(scene_name);
91
91
+
Ok(())
92
92
+
}),
93
93
+
})
94
94
+
}
95
95
+
80
96
fn each_beat(
81
97
self,
82
98
render_function: &'static RenderFunction<AdditionalContext>,
···
104
120
) -> Self {
105
121
let beats = match unit {
106
122
MusicalDurationUnit::Beats => amount,
107
107
-
MusicalDurationUnit::Halfs => amount / 2.0,
123
123
+
MusicalDurationUnit::Halves => amount / 2.0,
108
124
MusicalDurationUnit::Quarters => amount / 4.0,
109
125
MusicalDurationUnit::Eighths => amount / 8.0,
110
126
MusicalDurationUnit::Sixteenths => amount / 16.0,
···
133
149
) -> Self {
134
150
self.with_hook(Hook {
135
151
when: Box::new(move |_, context, _, previous_rendered_frame| {
136
136
-
context.frame() != previous_rendered_frame
137
137
-
&& context.frame() % n == 0
152
152
+
context.frame() - previous_rendered_frame >= n
138
153
}),
139
154
render_function: Box::new(render_function),
140
155
})