fix mask coords... might wanna change cpu output?

This commit is contained in:
2025-11-20 23:01:01 -05:00
parent dff72d2c43
commit acd67179b7
2 changed files with 18 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ pub struct Masked {
impl Widget for Masked { impl Widget for Masked {
fn draw(&mut self, painter: &mut Painter) { fn draw(&mut self, painter: &mut Painter) {
println!("yahoo! {}", painter.region());
painter.set_mask(painter.region()); painter.set_mask(painter.region());
painter.widget(&self.inner); painter.widget(&self.inner);
} }

View File

@@ -21,8 +21,18 @@ struct TextureInfo {
} }
struct Mask { struct Mask {
top_left: UiVec2, x: UiSpan,
bot_right: UiVec2, y: UiSpan,
}
struct UiSpan {
start: UiScalar,
end: UiScalar,
}
struct UiScalar {
rel: f32,
abs: f32,
} }
struct UiVec2 { struct UiVec2 {
@@ -121,8 +131,11 @@ fn fs_main(
} }
if in.mask_idx != 4294967295u { if in.mask_idx != 4294967295u {
let mask = masks[in.mask_idx]; let mask = masks[in.mask_idx];
let top_left = floor(mask.top_left.rel * window.dim) + floor(mask.top_left.abs); let tl = UiVec2(vec2(mask.x.start.rel, mask.y.start.rel), vec2(mask.x.start.abs, mask.y.start.abs));
let bot_right = floor(mask.bot_right.rel * window.dim) + floor(mask.bot_right.abs); let br = UiVec2(vec2(mask.x.end.rel, mask.y.end.rel), vec2(mask.x.end.abs, mask.y.end.abs));
let top_left = floor(tl.rel * window.dim) + floor(tl.abs);
let bot_right = floor(br.rel * window.dim) + floor(br.abs);
if pos.x < top_left.x || pos.x > bot_right.x || pos.y < top_left.y || pos.y > bot_right.y { if pos.x < top_left.x || pos.x > bot_right.x || pos.y < top_left.y || pos.y > bot_right.y {
color *= 0.0; color *= 0.0;
} }