Skip to content

Commit

Permalink
fix: refactor text layout and quad generation in debug scene
Browse files Browse the repository at this point in the history
- remove unnecessary code related to `instancedquad` from `src/scene/quad.rs`
- correct the function call to `add_text_layout` in `gen_debug_scene.rs`
- fix the initialization of `rect` in `gen_debug_scene.rs`
- adjust the position calculation in `gen_debug_scene.rs` for the `add_quad` function
- correct the function call to `add_text_layout` in `gen_debug_scene.rs` for `mask_layer`
  • Loading branch information
falcucci committed Sep 22, 2024
2 parents 4b05a1c + 04a635d commit 2a73c0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion crates/scene_viewer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ impl ApplicationHandler for App {
)
.with_edge_blur(5.0),
);

self.renderer.as_mut().unwrap().draw(&scene);
}
WindowEvent::Resized(new_size) => {
Expand Down
13 changes: 7 additions & 6 deletions gen_debug_scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() {
let layout = shaper.layout_with("Sphinx of black quartz judge my vow.", |builder| {
builder.push_default(&StyleProperty::FontSize(font_size));
});
scene.add_text_layout(layout, point2!(0., bottom));
scene.add_text_layout(&layout, point2!(0., bottom));
}

scene.add_layer(
Expand All @@ -41,8 +41,7 @@ fn main() {
.with_quadratic_bezier_to(point2!(180., 180.), point2!(20., 180.)),
)
.with_quad(Quad::new(
point2!(150., 100.),
size2!(100., 100.),
Rect::new(point2!(150., 100.), size2!(100., 100.)),
Srgba::new(1., 0., 0., 1.),
)),
);
Expand All @@ -59,8 +58,10 @@ fn main() {

for (i, color) in colors.iter().enumerate() {
scene.add_quad(Quad::new(
point2!(500., 10.) + vec2!(i as f32 * 10., i as f32 * 10.),
size2!(50., 50.),
Rect::new(
point2!(500., 10.) + vec2!(i as f32 * 10., i as f32 * 10.),
size2!(50., 50.),
),
*color,
));
}
Expand All @@ -75,7 +76,7 @@ fn main() {
let layout = shaper.layout_with("TestTestTestTestTestTestTestTest", |builder| {
builder.push_default(&StyleProperty::FontSize(15.));
});
mask_layer.add_text_layout(&mut scene.resources, layout, point2!(500., bottom));
mask_layer.add_text_layout(&mut scene.resources, &layout, point2!(500., bottom));
}

scene.set_mask(mask_layer);
Expand Down
3 changes: 2 additions & 1 deletion src/scene/quad.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::default_drawables::InstancedQuad;
use glam::Vec4;
use glamour::{AsRaw, Rect};
use palette::Srgba;
use serde::{Deserialize, Serialize};

use crate::default_drawables::InstancedQuad;

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Quad {
pub region: Rect,
Expand Down

0 comments on commit 2a73c0a

Please sign in to comment.