feat: Enhance Bevel & Emboss effect with contour support and algorithm improvements
- Implemented contour lookup functionality for Bevel & Emboss effect to allow for custom contour curves. - Added contour parameter to LayerStyle and updated related structures and functions. - Improved emboss algorithm by fixing height field calculations and ensuring proper handling of outside pixels. - Introduced tilt component for 3D emboss effect, enhancing visual depth. - Optimized MAE grid search parameters for better performance and accuracy. - Expanded Iced GUI panel for Bevel & Emboss to include contour selection and additional styling options. - Updated example scripts to reflect changes in the API and new features.
This commit is contained in:
@@ -60,7 +60,7 @@ fn protocol_effect_to_style(fx: &hcie_protocol::effects::LayerEffect) -> Option<
|
||||
E::InnerGlow { enabled, opacity, choke, size, color, blend_mode, .. } => {
|
||||
Some(S::InnerGlow { enabled: *enabled, opacity: *opacity, spread: *choke, size: *size, color: *color, blend_mode: blend_mode.clone() })
|
||||
}
|
||||
E::BevelEmboss { enabled, depth, size, angle, altitude, highlight_opacity, shadow_opacity, direction, style, technique, soften, highlight_blend, highlight_color, shadow_blend, shadow_color, .. } => {
|
||||
E::BevelEmboss { enabled, depth, size, angle, altitude, highlight_opacity, shadow_opacity, direction, style, technique, soften, highlight_blend, highlight_color, shadow_blend, shadow_color, contour, .. } => {
|
||||
let dir_str = match direction {
|
||||
hcie_protocol::effects::Direction::Up => "Up".to_string(),
|
||||
hcie_protocol::effects::Direction::Down => "Down".to_string(),
|
||||
@@ -93,6 +93,13 @@ fn protocol_effect_to_style(fx: &hcie_protocol::effects::LayerEffect) -> Option<
|
||||
highlight_color: *highlight_color,
|
||||
shadow_blend_mode: shadow_blend.clone(),
|
||||
shadow_color: *shadow_color,
|
||||
contour: contour.as_ref().map(|c| {
|
||||
// Convert ContourCurve back to a name for the protocol LayerStyle
|
||||
// For now, we'll use a simplified mapping
|
||||
if c.points.len() <= 2 { "Linear".to_string() }
|
||||
else if c.points.len() == 3 && c.points[1].1 > 0.5 { "Cone".to_string() }
|
||||
else { "Linear".to_string() }
|
||||
}).unwrap_or_else(|| "Linear".to_string()),
|
||||
})
|
||||
}
|
||||
E::Satin { enabled, opacity, angle, distance, size, color, invert, .. } => {
|
||||
@@ -1824,6 +1831,7 @@ impl Engine {
|
||||
style: String::new(), technique: String::new(), soften: 0.0,
|
||||
highlight_blend_mode: String::new(), highlight_color: [0; 4],
|
||||
shadow_blend_mode: String::new(), shadow_color: [0; 4],
|
||||
contour: "Linear".to_string(),
|
||||
},
|
||||
)),
|
||||
5 => Some(std::mem::discriminant(
|
||||
@@ -1858,7 +1866,7 @@ impl Engine {
|
||||
1 => S::InnerShadow { enabled: false, opacity: 0.0, angle: 0.0, distance: 0.0, spread: 0.0, size: 0.0, color: [0; 4], blend_mode: String::new() },
|
||||
2 => S::OuterGlow { enabled: false, opacity: 0.0, spread: 0.0, size: 0.0, color: [0; 4], blend_mode: String::new() },
|
||||
3 => S::InnerGlow { enabled: false, opacity: 0.0, spread: 0.0, size: 0.0, color: [0; 4], blend_mode: String::new() },
|
||||
4 => S::BevelEmboss { enabled: false, depth: 0.0, size: 0.0, angle: 0.0, altitude: 0.0, highlight_opacity: 0.0, shadow_opacity: 0.0, direction: String::new(), style: String::new(), technique: String::new(), soften: 0.0, highlight_blend_mode: String::new(), highlight_color: [0; 4], shadow_blend_mode: String::new(), shadow_color: [0; 4] },
|
||||
4 => S::BevelEmboss { enabled: false, depth: 0.0, size: 0.0, angle: 0.0, altitude: 0.0, highlight_opacity: 0.0, shadow_opacity: 0.0, direction: String::new(), style: String::new(), technique: String::new(), soften: 0.0, highlight_blend_mode: String::new(), highlight_color: [0; 4], shadow_blend_mode: String::new(), shadow_color: [0; 4], contour: "Linear".to_string() },
|
||||
5 => S::Satin { enabled: false, opacity: 0.0, angle: 0.0, distance: 0.0, size: 0.0, color: [0; 4], invert: false },
|
||||
6 => S::ColorOverlay { enabled: false, opacity: 0.0, color: [0; 4], blend_mode: String::new() },
|
||||
7 => S::GradientOverlay { enabled: false, opacity: 0.0, blend_mode: String::new(), angle: 0.0, scale: 0.0, gradient_type: 0 },
|
||||
|
||||
Reference in New Issue
Block a user