MiMo 2.5 feat: enhance vector shape handling with angle snapping and color state management

This commit is contained in:
2026-07-21 05:08:08 +03:00
parent b49106dc1d
commit cbe03f74a3
7 changed files with 194 additions and 20 deletions
@@ -1019,6 +1019,11 @@ impl<'a> egui::Widget for CanvasWidget<'a> {
.engine
.vector_shape_angle(layer_id, shape_idx);
angle += da;
let shift = ui.input(|i| i.modifiers.shift);
if shift {
let step = std::f32::consts::PI / 12.0;
angle = (angle / step).round() * step;
}
self.doc
.engine
.set_vector_shape_angle(layer_id, shape_idx, angle);
@@ -2230,10 +2235,15 @@ fn create_shape_from_drag(
let mut p = std::collections::HashMap::new();
p.insert("thick".to_string(), 0.0);
match hcie_engine_api::create_vector_shape("arrow", x1, y1, x2, y2, &p) {
VectorShape::SvgShape { kind, svg, .. } => VectorShape::SvgShape {
name: String::new(), kind, svg, x1, y1, x2, y2, stroke, color, fill_color, fill,
angle: 0.0, opacity, hardness,
},
VectorShape::SvgShape { kind, svg, .. } => {
// Derive the arrow's rotation from the drag direction so
// it points along the line drawn by the user.
let arrow_angle = (y2 - y1).atan2(x2 - x1);
VectorShape::SvgShape {
name: String::new(), kind, svg, x1, y1, x2, y2, stroke, color, fill_color, fill,
angle: arrow_angle, opacity, hardness,
}
}
_ => unreachable!(),
}
},