Skip to content

Commit

Permalink
Render margin in debug overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Sep 17, 2024
1 parent e6fe201 commit 2d9915c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/blitz/src/renderer/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ impl<'dom> VelloSceneGenerator<'dom> {
size,
border,
padding,
margin,
..
} = node.final_layout;
let taffy::Size { width, height } = size;
Expand All @@ -158,6 +159,7 @@ impl<'dom> VelloSceneGenerator<'dom> {
let scaled_pb = padding_border.map(|v| f64::from(v) * scale);
let scaled_padding = padding.map(|v| f64::from(v) * scale);
let scaled_border = border.map(|v| f64::from(v) * scale);
let scaled_margin = margin.map(|v| f64::from(v) * scale);

let content_width = width - padding_border.left - padding_border.right;
let content_height = height - padding_border.top - padding_border.bottom;
Expand Down Expand Up @@ -256,6 +258,18 @@ impl<'dom> VelloSceneGenerator<'dom> {
scaled_border.map(f64::from),
border_color,
);

let margin_color = Color::rgba(249.0 / 255.0, 204.0 / 245.0, 157.0 / 255.0, 0.5); // orange
draw_cutout_rect(
scene,
base_translation - Vec2::new(scaled_margin.left, scaled_margin.top),
Vec2::new(
width + scaled_margin.left + scaled_margin.right,
height + scaled_margin.top + scaled_margin.bottom,
),
scaled_margin.map(f64::from),
margin_color,
);
}

/// Renders a node, but is guaranteed that the node is an element
Expand Down

0 comments on commit 2d9915c

Please sign in to comment.