feat: Add theme and font management for egui GUI
- Introduced `theme.rs` to handle visual themes, font discovery, and application of theme colors. - Implemented system font registration for Linux, macOS, and Windows. - Added `apply_theme` function to configure egui visuals based on selected theme presets. feat: Implement interactive tool state management - Created `tool_state.rs` to manage runtime tool, selection, and transform states. - Defined `ToolState` struct to encapsulate active tool, color settings, drawing states, and AI panel states. - Included functionality for managing brush presets, text editing, and selection transformations. feat: Add utility functions for image and file handling - Developed `utils.rs` with stateless helper functions for color formatting, drawing icons, and cropping images. - Implemented save dialog builders and error handling for file operations. - Added flood fill functionality for composite RGBA pixels. test: Add unit test for bitmap brush stamp functionality - Created `bitmap_brush_stamp.rs` to verify the behavior of bitmap brush stamping in the engine. - Ensured that the painted area matches expected dimensions and characteristics.
This commit is contained in:
+17
-2
@@ -64,6 +64,19 @@ pub fn draw_brush_stroke(
|
||||
None
|
||||
};
|
||||
|
||||
// Pre-generate a bitmap stamp once for the whole stroke. Bitmap brushes
|
||||
// ignore the procedural shape and use the imported/sampled alpha mask.
|
||||
let bitmap_stamp = if tip.style == BrushStyle::Bitmap
|
||||
&& !tip.bitmap_pixels.is_empty()
|
||||
&& tip.bitmap_w > 0
|
||||
&& tip.bitmap_h > 0
|
||||
{
|
||||
Some(hcie_brush_engine::generate_brush_stamp(tip))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let stamp_ref = bitmap_stamp.as_deref();
|
||||
|
||||
let mut last_p = points[0];
|
||||
let (jx0, jy0) = jitter_offset(tip.jitter_amount, tip.size);
|
||||
let first_x = last_p.0 + jx0;
|
||||
@@ -79,10 +92,11 @@ pub fn draw_brush_stroke(
|
||||
first_color[0], first_color[1], first_color[2],
|
||||
(first_color[3] as f32 * first_opacity).round() as u8,
|
||||
];
|
||||
hcie_brush_engine::draw_dab_capped(
|
||||
hcie_brush_engine::draw_dab_capped_with_stamp(
|
||||
&mut layer.pixels, layer.width, layer.height,
|
||||
first_x, first_y, first_size, tip.hardness, first_px_color, 1.0, is_eraser, mask,
|
||||
stroke_mask.as_deref_mut(), bg_pixels, tip.opacity,
|
||||
stamp_ref,
|
||||
);
|
||||
|
||||
for &p in &points[1..] {
|
||||
@@ -116,10 +130,11 @@ pub fn draw_brush_stroke(
|
||||
dab_color[0], dab_color[1], dab_color[2],
|
||||
(dab_color[3] as f32 * pressure_opacity).round() as u8,
|
||||
];
|
||||
hcie_brush_engine::draw_dab_capped(
|
||||
hcie_brush_engine::draw_dab_capped_with_stamp(
|
||||
&mut layer.pixels, layer.width, layer.height,
|
||||
final_x, final_y, effective_size, tip.hardness, px_color, 1.0, is_eraser, mask,
|
||||
stroke_mask.as_deref_mut(), bg_pixels, tip.opacity,
|
||||
stamp_ref,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user