src
geometry
graphics
random
rendering
synchronization
video
···
1
1
-
2
1
/// Angle, stored in degrees
3
2
#[derive(Debug, Clone, Copy, Default)]
4
3
pub struct Angle(pub f32);
···
1
1
use crate::{Object, Point};
2
2
use anyhow::{format_err, Error, Result};
3
3
use backtrace::Backtrace;
4
4
-
use rand::Rng;
5
4
use wasm_bindgen::prelude::*;
6
5
7
6
#[wasm_bindgen]
···
1
1
use core::panic;
2
2
-
use rayon::prelude::*;
3
2
use resvg::usvg;
4
3
use std::{collections::HashMap, ops::Range, sync::Arc};
5
4
6
5
use itertools::Itertools as _;
7
6
use measure_time::info_time;
8
8
-
use rand::Rng;
9
7
10
8
use crate::{
11
9
fonts::{load_fonts, FontOptions},
12
12
-
geometry::region::Containable,
13
13
-
Color, ColorMapping, ColoredObject, Fill, Filter, Layer, LineSegment, Object, ObjectSizes,
14
14
-
Point, Region,
10
10
+
Color, ColorMapping, Fill, Filter, Layer, Object, ObjectSizes, Point, Region,
15
11
};
16
12
17
13
#[derive(Debug, Clone)]
···
2
2
3
3
use wasm_bindgen::prelude::*;
4
4
5
5
-
6
5
#[wasm_bindgen]
7
6
#[derive(Debug, Clone, Copy, PartialEq)]
8
7
pub enum FilterType {
···
1
1
-
use crate::{ColorMapping, ColoredObject, Fill, Filter, ObjectSizes, Region, Toggleable};
1
1
+
use crate::{ColoredObject, Fill, Filter, ObjectSizes, Region, Toggleable};
2
2
use std::{collections::HashMap, fmt::Display};
3
3
4
4
#[derive(Debug, Clone, Default)]
···
10
10
pub hidden: bool,
11
11
pub _render_cache: Option<svg::node::element::Group>,
12
12
}
13
13
-
14
14
-
static DISABLE_CACHE: bool = true;
15
13
16
14
impl Layer {
17
15
pub fn new(name: &str) -> Self {
···
6
6
pub mod objects;
7
7
pub mod transform;
8
8
9
9
+
pub use canvas::Canvas;
9
10
pub use color::{Color, ColorMapping};
10
11
pub use fill::Fill;
11
12
pub use filter::{Filter, FilterType};
12
13
pub use layer::Layer;
13
14
pub use objects::{ColoredObject, LineSegment, Object, ObjectSizes};
14
15
pub use transform::{Transformation, TransformationType};
15
15
-
pub use canvas::Canvas;
···
1
1
-
use crate::{ColorMapping, Fill, Filter, Point, Region, Transformation};
2
2
-
use std::collections::HashMap;
1
1
+
use crate::{Fill, Filter, Point, Region, Transformation};
3
2
use wasm_bindgen::prelude::*;
4
3
5
4
#[derive(Debug, Clone, PartialEq, Eq)]
···
61
61
canvas.root().clear();
62
62
canvas.root().add_object(
63
63
"text",
64
64
-
Object::CenteredText(
65
65
-
center,
66
66
-
format!("{}", ctx.timestamp),
67
67
-
30.0,
68
68
-
)
69
69
-
.color(Fill::Solid(Color::White)),
64
64
+
Object::CenteredText(center, ctx.timestamp.to_string(), 30.0)
65
65
+
.color(Fill::Solid(Color::White)),
70
66
);
71
67
canvas.root().add_object(
72
68
"beat",
73
73
-
Object::CenteredText(
74
74
-
center.translated(0, 3),
75
75
-
format!("beat {}", ctx.beat),
76
76
-
30.0,
77
77
-
).color(Fill::Solid(Color::Cyan)),
69
69
+
Object::CenteredText(center.translated(0, 3), format!("beat {}", ctx.beat), 30.0)
70
70
+
.color(Fill::Solid(Color::Cyan)),
78
71
);
79
72
Ok(())
80
73
})
···
1
1
-
use crate::{Canvas, ColoredObject, Containable, Fill, Layer, LineSegment, Object, Point, Region};
1
1
+
use crate::{Canvas, ColoredObject, Fill, Layer, Object, Region};
2
2
use rand::{distributions::uniform::SampleRange, Rng};
3
3
use std::collections::HashMap;
4
4
···
38
38
);
39
39
}
40
40
Layer {
41
41
-
object_sizes: self.object_sizes.clone(),
41
41
+
object_sizes: self.object_sizes,
42
42
name: layer_name.to_owned(),
43
43
objects,
44
44
_render_cache: None,
···
94
94
95
95
pub fn random_region(&self) -> Region {
96
96
Region::random(&self.world_region)
97
97
-
}
98
98
-
99
99
-
pub(crate) fn random_point(&self, region: &Region) -> Point {
100
100
-
Point::random(region)
101
97
}
102
98
}
···
3
3
pub mod fill;
4
4
pub mod layer;
5
5
pub mod objects;
6
6
-
pub mod region;
7
6
pub mod point;
7
7
+
pub mod region;
8
8
9
9
-
pub use canvas::*;
10
9
pub use color::*;
11
11
-
pub use fill::*;
12
12
-
pub use layer::*;
13
13
-
pub use objects::*;
14
14
-
pub use region::*;
15
15
-
pub use point::*;
···
1
1
-
use std::collections::HashMap;
2
2
-
3
1
use rand::{distributions::uniform::SampleRange, Rng};
4
2
5
5
-
use crate::{ColoredObject, Layer, LineSegment, Object, ObjectSizes, Point, Region};
3
3
+
use crate::{LineSegment, Object, Point, Region};
6
4
7
5
impl Object {
8
6
pub fn random_starting_at(
···
42
40
_ => unreachable!(),
43
41
}
44
42
}
45
45
-
46
43
47
44
pub fn random(
48
45
region: &Region,
···
5
5
impl SVGRenderable for Filter {
6
6
fn render_to_svg(
7
7
&self,
8
8
-
colormap: crate::ColorMapping,
9
9
-
cell_size: usize,
10
10
-
object_sizes: crate::graphics::objects::ObjectSizes,
11
11
-
id: &str,
8
8
+
_colormap: crate::ColorMapping,
9
9
+
_cell_size: usize,
10
10
+
_object_sizes: crate::graphics::objects::ObjectSizes,
11
11
+
_id: &str,
12
12
) -> anyhow::Result<svg::node::element::Element> {
13
13
{
14
14
Ok(match self.kind {
···
4
4
5
5
use super::renderable::SVGRenderable;
6
6
7
7
-
static DISABLE_CACHE: bool = true;
8
8
-
9
7
impl SVGRenderable for Layer {
10
8
fn render_to_svg(
11
11
-
&self,
9
9
+
&self,
12
10
colormap: crate::ColorMapping,
13
11
cell_size: usize,
14
12
object_sizes: crate::graphics::objects::ObjectSizes,
···
25
23
colormap.clone(),
26
24
cell_size,
27
25
object_sizes,
28
28
-
&vec![id, object_id].join("--"),
26
26
+
&[id, object_id].join("--"),
29
27
)?);
30
28
}
31
29
···
1
1
-
pub mod midi;
2
1
pub mod audio;
2
2
+
pub mod midi;
3
3
pub mod sync;
···
1
1
use super::animation::{AnimationUpdateFunction, LayerAnimationUpdateFunction};
2
2
-
use super::video::{LaterHook, LaterRenderFunction};
2
2
+
use super::engine::{LaterHook, LaterRenderFunction};
3
3
use super::Animation;
4
4
use crate::synchronization::audio::StemAtInstant;
5
5
use crate::synchronization::sync::SyncData;
···
1
1
pub mod animation;
2
2
pub mod context;
3
3
-
pub mod video;
3
3
+
pub mod engine;
4
4
5
5
-
pub use video::Video;
6
5
pub use animation::Animation;
6
6
+
pub use engine::Video;
···
582
582
let (hwc_frames_send, hwc_frames_receive) =
583
583
std::sync::mpsc::channel::<(Time, video_rs::Frame)>();
584
584
585
585
-
let resolution = self.resolution.clone();
585
585
+
let resolution = self.resolution;
586
586
let pb = self.progress_bar.clone();
587
587
let canvas = self.initial_canvas.clone();
588
588
frames_to_encode.par_iter().for_each(|(time, svg)| {
589
589
let (width, height) = canvas.resolution_to_size(resolution);
590
590
let pixmap = canvas
591
591
-
.svg_to_pixmap(width, height, &svg)
591
591
+
.svg_to_pixmap(width, height, svg)
592
592
.expect("Failed to render frame");
593
593
594
594
let frame = canvas