Skip to content

Commit

Permalink
Merge pull request #11 from waywardmonkeys/use-Default-default-rather…
Browse files Browse the repository at this point in the history
…-than-bevy-util

typst_vello: Use `Default::default()`
  • Loading branch information
nixon-voxell authored Sep 16, 2024
2 parents e908d17 + d0760fd commit fe65285
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
21 changes: 15 additions & 6 deletions crates/typst_vello/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pub use typst;

use bevy_utils::{default, HashMap};
use bevy_utils::HashMap;
use image::{render_image, ImageScene};
use shape::{convert_path, render_shape, ShapeScene};
use text::{render_text, TextScene};
Expand Down Expand Up @@ -32,9 +32,15 @@ pub struct TypstScene {
impl TypstScene {
pub fn from_frame(frame: &Frame) -> Self {
let size = kurbo::Vec2::new(frame.size().x.to_pt(), frame.size().y.to_pt());
let mut typst_scene = TypstScene { size, ..default() };
let mut typst_scene = TypstScene {
size,
..Default::default()
};

let group_paths = TypstGroup { size, ..default() };
let group_paths = TypstGroup {
size,
..Default::default()
};
typst_scene.append_group(group_paths);
typst_scene.handle_frame(
frame,
Expand Down Expand Up @@ -167,7 +173,7 @@ impl TypstScene {
parent,
clip_path: group.clip_path.as_ref().map(convert_path),
label: group.label,
..default()
..Default::default()
};

// Update state based on group frame.
Expand Down Expand Up @@ -246,7 +252,10 @@ pub struct TypstGroupScene {

impl TypstGroupScene {
pub fn new(group: TypstGroup) -> Self {
Self { group, ..default() }
Self {
group,
..Default::default()
}
}
}

Expand Down Expand Up @@ -275,7 +284,7 @@ impl TypstGroup {
Self {
scenes: vec![scene],
parent,
..default()
..Default::default()
}
}

Expand Down
3 changes: 1 addition & 2 deletions crates/typst_vello/src/text.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use bevy_utils::default;
use ttf_parser::{GlyphId, OutlineBuilder};
use typst::{
layout::{Abs, Ratio, Transform},
Expand Down Expand Up @@ -86,7 +85,7 @@ pub fn render_text(
style: convert_fixed_stroke(stroke),
brush: convert_paint_to_brush(&stroke.paint, state.size),
}),
..default()
..Default::default()
};

let scale = text.size.to_pt() / text.font.units_per_em();
Expand Down
3 changes: 1 addition & 2 deletions crates/typst_vello/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::f32::consts::TAU;

use bevy_utils::default;
use typst::{
layout::{Quadrant, Size, Transform},
visualize as viz,
Expand All @@ -27,7 +26,7 @@ pub fn convert_fixed_stroke(stroke: &viz::FixedStroke) -> kurbo::Stroke {
miter_limit,
start_cap: cap,
end_cap: cap,
..default()
..Default::default()
};

if let Some(dash) = &stroke.dash {
Expand Down

0 comments on commit fe65285

Please sign in to comment.