From 88ef6cb9cf6872ae9ab8d617657163bbab56780b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=93=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=B7=D0=B4=D0=B8=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Aug 2024 23:43:59 +0300 Subject: [PATCH 1/2] fix overlay positioning --- Source/Model/Primitives/SVGGradient.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Model/Primitives/SVGGradient.swift b/Source/Model/Primitives/SVGGradient.swift index 42cafb5..c4b6ee8 100644 --- a/Source/Model/Primitives/SVGGradient.swift +++ b/Source/Model/Primitives/SVGGradient.swift @@ -81,7 +81,7 @@ public class SVGLinearGradient: SVGGradient { .scaleEffect(CGSize(width: width/maximum, height: height/maximum)) } .frame(width: width, height: height) - .offset(x: bounds.minX, y: bounds.minY) + .offset(x: frame.minX, y: frame.minY) .mask(view) ) } From a1bffa4537506b827ec341690b3e392c50459e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=93=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=B7=D0=B4=D0=B8=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Aug 2024 23:51:21 +0300 Subject: [PATCH 2/2] a bit of clarification the misbehavior is when the shape is a polygon --- Source/Model/Primitives/SVGGradient.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Model/Primitives/SVGGradient.swift b/Source/Model/Primitives/SVGGradient.swift index c4b6ee8..2239852 100644 --- a/Source/Model/Primitives/SVGGradient.swift +++ b/Source/Model/Primitives/SVGGradient.swift @@ -71,7 +71,8 @@ public class SVGLinearGradient: SVGGradient { let width = bounds.width let height = bounds.height let maximum = max(width, height) - + let offsetRect = model is SVGPolygon ? frame : bounds + return view .foregroundColor(.clear) .overlay( @@ -81,7 +82,7 @@ public class SVGLinearGradient: SVGGradient { .scaleEffect(CGSize(width: width/maximum, height: height/maximum)) } .frame(width: width, height: height) - .offset(x: frame.minX, y: frame.minY) + .offset(x: offsetRect.minX, y: offsetRect.minY) .mask(view) ) }