Skip to content

Commit de70263

Browse files
committed
Limit the stroke distance to half width
1 parent 5e80c66 commit de70263

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

editor/src/messages/portfolio/document/overlays/utility_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ impl OverlayContext {
732732
pub fn fill_path(&mut self, subpaths: impl Iterator<Item = impl Borrow<Subpath<PointId>>>, transform: DAffine2, color: &Color, with_pattern: bool, stroke_width: Option<f64>) {
733733
self.render_context.save();
734734
let transform_scale = transform.decompose_scale().x.max(transform.decompose_scale().y);
735-
self.render_context.set_line_width(stroke_width.unwrap_or(1.) * transform_scale + 2.0);
735+
self.render_context.set_line_width(stroke_width.unwrap_or(1.) * transform_scale);
736736
self.draw_path_from_subpaths(subpaths, transform);
737737

738738
if with_pattern {

editor/src/messages/tool/tool_messages/fill_tool.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::messages::portfolio::document::overlays::utility_types::OverlayContex
33
use crate::messages::tool::common_functionality::graph_modification_utils::{self, NodeGraphLayer, get_stroke_width};
44
use graph_craft::document::value::TaggedValue;
55
use graphene_core::vector::style::Fill;
6+
use graphene_std::transform::Transform;
67
use graphene_std::vector::PointId;
78
use graphene_std::vector::style::Stroke;
89

@@ -76,12 +77,14 @@ impl ToolTransition for FillTool {
7677
}
7778

7879
pub fn close_to_subpath(mouse_pos: DVec2, subpath: bezier_rs::Subpath<PointId>, stroke_width: f64, to_viewport_transform: DAffine2) -> bool {
79-
let stroke_width = stroke_width + 1.0;
8080
let mouse_pos = to_viewport_transform.inverse().transform_point2(mouse_pos);
81+
let transform_scale = to_viewport_transform.decompose_scale().x.max(to_viewport_transform.decompose_scale().y);
82+
let threshold = (2.0 - transform_scale).exp2();
83+
let max_stroke_distance = stroke_width * 0.5 + threshold;
8184

8285
if let Some((segment_index, t)) = subpath.project(mouse_pos) {
8386
let nearest_point = subpath.evaluate(bezier_rs::SubpathTValue::Parametric { segment_index, t });
84-
(mouse_pos - nearest_point).length() <= stroke_width
87+
(mouse_pos - nearest_point).length() <= max_stroke_distance
8588
} else {
8689
false
8790
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy