mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Fix ellipse tool behavior (#105)
This commit is contained in:
parent
3431128e66
commit
b4ad274fd8
1 changed files with 8 additions and 3 deletions
|
|
@ -135,10 +135,14 @@ fn make_operation(data: &EllipseToolData, tool_data: &DocumentToolData) -> Opera
|
|||
let x1 = data.drag_current.x as f64;
|
||||
let y1 = data.drag_current.y as f64;
|
||||
|
||||
let (cx, cy, r_scale) = if data.center_around_cursor { (x0, y0, 1.0) } else { ((x0 + x1) * 0.5, (y0 + y1) * 0.5, 0.5) };
|
||||
|
||||
if data.constrain_to_circle {
|
||||
let r = f64::max((x1 - x0).abs(), (y1 - y0).abs()) * r_scale;
|
||||
let (cx, cy, r) = if data.center_around_cursor {
|
||||
(x0, y0, f64::hypot(x1 - x0, y1 - y0))
|
||||
} else {
|
||||
let diameter = f64::max((x1 - x0).abs(), (y1 - y0).abs());
|
||||
let (x2, y2) = (x0 + (x1 - x0).signum() * diameter, y0 + (y1 - y0).signum() * diameter);
|
||||
((x0 + x2) * 0.5, (y0 + y2) * 0.5, diameter * 0.5)
|
||||
};
|
||||
Operation::AddCircle {
|
||||
path: vec![],
|
||||
insert_index: -1,
|
||||
|
|
@ -148,6 +152,7 @@ fn make_operation(data: &EllipseToolData, tool_data: &DocumentToolData) -> Opera
|
|||
style: style::PathStyle::new(None, Some(style::Fill::new(tool_data.primary_color))),
|
||||
}
|
||||
} else {
|
||||
let (cx, cy, r_scale) = if data.center_around_cursor { (x0, y0, 1.0) } else { ((x0 + x1) * 0.5, (y0 + y1) * 0.5, 0.5) };
|
||||
let (rx, ry) = ((x1 - x0).abs() * r_scale, (y1 - y0).abs() * r_scale);
|
||||
Operation::AddEllipse {
|
||||
path: vec![],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue