From 22d9958d18a0af19403399fe02656ab8e6f14214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 10 Sep 2026 10:51:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=88=86=E7=A6=BB=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E5=9B=BE=E4=B8=AD=E9=81=AE=E7=BD=A9=E6=99=AE=E9=80=9A=E6=96=87?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 绘制文字紫色区域并保持绿色元素框在最上层 增加文字遮罩图层顺序测试 --- .../ui_editor/commands/separation/marker.rs | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/marker.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/marker.rs index 9c8cfd120..b02abafe1 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/marker.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/marker.rs @@ -1,9 +1,10 @@ -use super::model::SeparationNode; +use super::model::{SeparationNode, SeparationNote, TextMaskArea}; use base64::Engine as _; use std::path::Path; use std::path::PathBuf; const MARKER_LINE_WIDTH: u32 = 2; +const PURPLE_FILL: image::Rgba = image::Rgba([180, 0, 180, 120]); pub async fn build_marked_image( source_url: String, @@ -41,7 +42,19 @@ fn build_marked_image_blocking( child.global_pos_y_px, child.width_px, child.height_px, - image::Rgba([180, 0, 180, 120]), + PURPLE_FILL, + width, + height, + ); + } + for mask in &node.text_mask_areas { + fill_rect( + &mut image, + mask.global_pos_x_px, + mask.global_pos_y_px, + mask.width_px, + mask.height_px, + PURPLE_FILL, width, height, ); @@ -262,4 +275,48 @@ mod tests { } assert_eq!(*image.get_pixel(1, 1), image::Rgba([1, 2, 3, 255])); } + + #[test] + fn text_mask_is_purple_before_green_frame() { + let mut image = image::RgbaImage::from_pixel(8, 8, image::Rgba([1, 2, 3, 255])); + let node = SeparationNode { + id: crate::ui_editor::utils::NodeId::new("image").unwrap(), + global_pos_x_px: 1, + global_pos_y_px: 1, + width_px: 6, + height_px: 6, + note: SeparationNote::default(), + text_mask_areas: vec![TextMaskArea { + global_pos_x_px: 2, + global_pos_y_px: 3, + width_px: 2, + height_px: 2, + }], + children: vec![], + rework_count: 0, + }; + for mask in &node.text_mask_areas { + fill_rect( + &mut image, + mask.global_pos_x_px, + mask.global_pos_y_px, + mask.width_px, + mask.height_px, + PURPLE_FILL, + 8, + 8, + ); + } + draw_frame( + &mut image, + node.global_pos_x_px, + node.global_pos_y_px, + node.width_px, + node.height_px, + 8, + 8, + ); + assert_eq!(*image.get_pixel(2, 4), PURPLE_FILL); + assert_eq!(*image.get_pixel(1, 1), image::Rgba([0, 255, 0, 255])); + } }