@@ -428,14 +428,14 @@ impl OverlayContext {
428428
429429 /// Fills the shape's fill region with a pattern of the given color. Assumes `color` is in gamma space.
430430 /// Used by the fill tool to show the area to be filled.
431- pub fn fill_overlay ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , transform : DAffine2 , color : & Color , stroke : Option < Stroke > ) {
432- self . internal ( ) . fill_overlay ( subpaths, transform, color, stroke) ;
431+ pub fn fill_overlay ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , is_closed_on_all : bool , transform : DAffine2 , color : & Color , stroke : Option < Stroke > ) {
432+ self . internal ( ) . fill_overlay ( subpaths, is_closed_on_all , transform, color, stroke) ;
433433 }
434434
435435 /// Fills the shape's fill region with a pattern of the given color. Assumes `color` is in gamma space.
436436 /// https://www.w3schools.com/tags/canvas_globalcompositeoperation.asp
437- pub fn stroke_overlay ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , transform : DAffine2 , color : & Color , stroke : Option < Stroke > ) {
438- self . internal ( ) . stroke_overlay ( subpaths, transform, color, stroke) ;
437+ pub fn stroke_overlay ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , is_closed_on_all : bool , transform : DAffine2 , color : & Color , stroke : Option < Stroke > ) {
438+ self . internal ( ) . stroke_overlay ( subpaths, is_closed_on_all , transform, color, stroke) ;
439439 }
440440
441441 pub fn text ( & self , text : & str , font_color : & str , background_color : Option < & str > , transform : DAffine2 , padding : f64 , pivot : [ Pivot ; 2 ] ) {
@@ -1002,7 +1002,7 @@ impl OverlayContextInternal {
10021002 path. push ( bezier. as_path_el ( ) ) ;
10031003 }
10041004
1005- fn path_from_subpaths ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , transform : DAffine2 ) -> BezPath {
1005+ fn path_from_subpaths ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , auto_close : bool , transform : DAffine2 ) -> BezPath {
10061006 let mut path = BezPath :: new ( ) ;
10071007
10081008 for subpath in subpaths {
@@ -1043,7 +1043,7 @@ impl OverlayContextInternal {
10431043 }
10441044 }
10451045
1046- if subpath. closed ( ) {
1046+ if subpath. closed ( ) && auto_close {
10471047 path. close_path ( ) ;
10481048 }
10491049 }
@@ -1065,7 +1065,7 @@ impl OverlayContextInternal {
10651065 }
10661066
10671067 if !subpaths. is_empty ( ) {
1068- let path = self . path_from_subpaths ( subpaths. iter ( ) , transform) ;
1068+ let path = self . path_from_subpaths ( subpaths. iter ( ) , true , transform) ;
10691069 let color = color. unwrap_or ( COLOR_OVERLAY_BLUE ) ;
10701070
10711071 self . scene . stroke ( & kurbo:: Stroke :: new ( 1. ) , self . get_transform ( ) , Self :: parse_color ( color) , None , & path) ;
@@ -1115,20 +1115,20 @@ impl OverlayContextInternal {
11151115 /// Fills the area inside the path. Assumes `color` is in gamma space.
11161116 /// Used by the Pen tool to show the path being closed.
11171117 fn fill_path ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , transform : DAffine2 , color : & str ) {
1118- let path = self . path_from_subpaths ( subpaths, transform) ;
1118+ let path = self . path_from_subpaths ( subpaths, true , transform) ;
11191119
11201120 self . scene . fill ( peniko:: Fill :: NonZero , self . get_transform ( ) , Self :: parse_color ( color) , None , & path) ;
11211121 }
11221122
11231123 /// Fills the shape's fill region with a pattern of the given color. Assumes `color` is in gamma space.
11241124 /// Used by the fill tool to show the area to be filled.
1125- fn fill_overlay ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , transform : DAffine2 , color : & Color , stroke : Option < Stroke > ) {
1125+ fn fill_overlay ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , is_closed_on_all : bool , transform : DAffine2 , color : & Color , stroke : Option < Stroke > ) {
11261126 if let Some ( stroke) = stroke {
11271127 let has_real_stroke = stroke. weight ( ) > 0. && stroke. transform . matrix2 . determinant ( ) != 0. ;
11281128 let applied_stroke_transform = if has_real_stroke { stroke. transform } else { transform } ;
11291129 let element_transform = if has_real_stroke { transform * stroke. transform . inverse ( ) } else { DAffine2 :: IDENTITY } ;
11301130
1131- let path = self . path_from_subpaths ( subpaths, applied_stroke_transform) ;
1131+ let path = self . path_from_subpaths ( subpaths, false , applied_stroke_transform) ;
11321132 let brush = peniko:: Brush :: Image ( self . fill_canvas_pattern_image ( color) ) ;
11331133
11341134 let do_fill = |scene : & mut Scene | {
@@ -1141,15 +1141,14 @@ impl OverlayContextInternal {
11411141 if let Some ( scale) = stroke_scale {
11421142 stroke. width *= scale;
11431143 }
1144- let path_bbox = path. bounding_box ( ) . inflate ( stroke. width , stroke. width ) ;
1144+ let path_bbox = path. bounding_box ( ) . inflate ( stroke. width * 1.5 , stroke. width * 1.5 ) ;
11451145
11461146 scene. push_layer ( peniko:: Fill :: NonZero , BlendMode :: new ( peniko:: Mix :: Normal , compose_mode) , 1.0 , element_transform, & path_bbox) ;
11471147 scene. stroke ( & stroke, element_transform, & brush, Some ( element_transform. inverse ( ) ) , & path) ;
11481148 scene. pop_layer ( ) ;
11491149 } ;
11501150
11511151 // For layers with open subpaths, stroke align is ignored and set to default
1152- let is_closed_on_all = true ;
11531152 let stroke_align = if is_closed_on_all { stroke. align } else { StrokeAlign :: Center } ;
11541153
11551154 match ( stroke_align, stroke. paint_order ) {
@@ -1173,21 +1172,21 @@ impl OverlayContextInternal {
11731172 }
11741173 }
11751174 } else {
1176- let path = self . path_from_subpaths ( subpaths, transform) ;
1175+ let path = self . path_from_subpaths ( subpaths, false , transform) ;
11771176 let brush = peniko:: Brush :: Image ( self . fill_canvas_pattern_image ( color) ) ;
11781177 self . scene . fill ( peniko:: Fill :: NonZero , Affine :: IDENTITY , & brush, None , & path) ;
11791178 }
11801179 }
11811180
11821181 /// Fills the shape's fill region with a pattern of the given color. Assumes `color` is in gamma space.
11831182 /// https://www.w3schools.com/tags/canvas_globalcompositeoperation.asp
1184- pub fn stroke_overlay ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , transform : DAffine2 , color : & Color , stroke : Option < Stroke > ) {
1183+ pub fn stroke_overlay ( & mut self , subpaths : impl Iterator < Item = impl Borrow < Subpath < PointId > > > , is_closed_on_all : bool , transform : DAffine2 , color : & Color , stroke : Option < Stroke > ) {
11851184 if let Some ( stroke) = stroke {
11861185 let has_real_stroke = stroke. weight ( ) > 0. && stroke. transform . matrix2 . determinant ( ) != 0. ;
11871186 let applied_stroke_transform = if has_real_stroke { stroke. transform } else { transform } ;
11881187 let element_transform = if has_real_stroke { transform * stroke. transform . inverse ( ) } else { DAffine2 :: IDENTITY } ;
11891188
1190- let path = self . path_from_subpaths ( subpaths, applied_stroke_transform) ;
1189+ let path = self . path_from_subpaths ( subpaths, false , applied_stroke_transform) ;
11911190 let brush = peniko:: Brush :: Image ( self . fill_canvas_pattern_image ( color) ) ;
11921191
11931192 let do_stroke = |scene : & mut Scene , stroke_scale : Option < f64 > | {
@@ -1201,7 +1200,7 @@ impl OverlayContextInternal {
12011200 } ;
12021201 let composite_fill_out = |scene : & mut Scene , compose_mode : peniko:: Compose , stroke_scale : Option < f64 > | {
12031202 let element_transform = Affine :: new ( element_transform. to_cols_array ( ) ) ;
1204- let stroke_width = stroke. weight ( ) * stroke_scale. map_or ( 1.0 , |scale| scale) ;
1203+ let stroke_width = stroke. weight ( ) * stroke_scale. map_or ( 1.0 , |scale| scale) * 1.5 ;
12051204 let path_bbox = path. bounding_box ( ) . inflate ( stroke_width, stroke_width) ;
12061205
12071206 scene. push_layer ( peniko:: Fill :: NonZero , BlendMode :: new ( peniko:: Mix :: Normal , compose_mode) , 1.0 , element_transform, & path_bbox) ;
@@ -1210,7 +1209,6 @@ impl OverlayContextInternal {
12101209 } ;
12111210
12121211 // For layers with open subpaths, stroke align is ignored and set to default
1213- let is_closed_on_all = true ;
12141212 let stroke_align = if is_closed_on_all { stroke. align } else { StrokeAlign :: Center } ;
12151213
12161214 match ( stroke_align, stroke. paint_order ) {
0 commit comments