diff --git a/assets/cursors/cursor-pen-convert.svg b/assets/cursors/cursor-pen-convert.svg index fa78f562ef..79e29af75d 100644 --- a/assets/cursors/cursor-pen-convert.svg +++ b/assets/cursors/cursor-pen-convert.svg @@ -1 +1,5 @@ - + + + + + diff --git a/assets/cursors/cursor-pen-curvature.svg b/assets/cursors/cursor-pen-curvature.svg index 94ba1708b5..b8d4bd3650 100644 --- a/assets/cursors/cursor-pen-curvature.svg +++ b/assets/cursors/cursor-pen-curvature.svg @@ -1 +1,5 @@ - + + + + + diff --git a/assets/cursors/cursor-pen-join.svg b/assets/cursors/cursor-pen-join.svg index 3dd7ce7f6e..05a020bb12 100644 --- a/assets/cursors/cursor-pen-join.svg +++ b/assets/cursors/cursor-pen-join.svg @@ -1 +1,6 @@ - + + + + + + diff --git a/assets/cursors/cursor-pen-new.svg b/assets/cursors/cursor-pen-new.svg index 6690b1ffd6..a27dc0ddae 100644 --- a/assets/cursors/cursor-pen-new.svg +++ b/assets/cursors/cursor-pen-new.svg @@ -1 +1,8 @@ - + + + + + + + + diff --git a/crates/ui-egui/src/cursors/tests.rs b/crates/ui-egui/src/cursors/tests.rs index 183bda8b47..8393e82004 100644 --- a/crates/ui-egui/src/cursors/tests.rs +++ b/crates/ui-egui/src/cursors/tests.rs @@ -55,3 +55,40 @@ fn every_cursor_icon_the_app_names_is_in_its_set() { } } } + +/// Painted cursors use the SVG's alpha as ink. Drawing the vent in white makes it solid ink. +#[test] +fn the_painted_pen_nibs_keep_their_breather_holes() { + use craft::ui::primitives::{painted_image, register_app_icons}; + use craft::ui::runtime::env::Env; + use craft::ui::style::rgba_color; + + register_app_icons(&crate::icons::APP_ICONS); + register_app_icons(&CURSOR_ICONS); + crate::testing::ui_context() + .run_ui(Default::default(), |ui| { + let env = Env::of(ui); + let tokens = env.tokens.tokens(); + let ink = rgba_color(tokens.color.overlay.cursor); + let is_ink = |px: &[u8]| px[3] >= 240 && [ink.r(), ink.g(), ink.b()].iter().zip(px).all(|(want, got)| want.abs_diff(*got) <= 8); + let scale = 4.0; + let from_art_units = tokens.size.icon.md * scale / 24.0; + for c in [Cursor::Pen, Cursor::PenConvert, Cursor::PenJoin, Cursor::Curvature] { + let cb::Cursor::Painted(painted @ PaintedCursor::Tool { hotspot, .. }) = tool_cursor(c) else { + panic!("{c:?} must have painted tool art"); + }; + let image = painted_image(&env, &painted, scale).expect("the cursor fits in its bitmap"); + let [hx, hy] = image.hotspot.map(f32::from); + let pixel = |x: f32, y: f32| { + let x = (hx + (x - hotspot.x) * from_art_units).round() as usize; + let y = (hy + (y - hotspot.y) * from_art_units).round() as usize; + let i = (y * usize::from(image.size[0]) + x) * 4; + &image.rgba[i..i + 4] + }; + assert!(is_ink(pixel(9.5, 13.2)), "{c:?}: the nib body is ink"); + assert!(!is_ink(pixel(6.62, 12.86)), "{c:?}: the vent must break up the ink"); + } + }) + .textures_delta + .clear(); +}