diff --git a/Source/model/scene/Shape.swift b/Source/model/scene/Shape.swift index f9cebe96..a86aae74 100644 --- a/Source/model/scene/Shape.swift +++ b/Source/model/scene/Shape.swift @@ -65,7 +65,7 @@ open class Shape: Node { ctx.replacePathWithStrokedPath() } - var rect = ctx.pathBounds + var rect = ctx.boundingBoxOfPath if rect.height == 0, rect.width == 0 && (rect.origin.x == CGFloat.infinity || rect.origin.y == CGFloat.infinity) { diff --git a/Source/render/ShapeRenderer.swift b/Source/render/ShapeRenderer.swift index f28cc5e3..69f5f417 100644 --- a/Source/render/ShapeRenderer.swift +++ b/Source/render/ShapeRenderer.swift @@ -191,7 +191,7 @@ class ShapeRenderer: NodeRenderer { var start = CGPoint(x: CGFloat(gradient.x1), y: CGFloat(gradient.y1)) var end = CGPoint(x: CGFloat(gradient.x2), y: CGFloat(gradient.y2)) if !gradient.userSpace { - let bounds = ctx!.pathBounds + let bounds = ctx!.boundingBoxOfPath start = CGPoint(x: start.x * bounds.width + bounds.minX, y: start.y * bounds.height + bounds.minY) end = CGPoint(x: end.x * bounds.width + bounds.minX, y: end.y * bounds.height + bounds.minY) } @@ -203,7 +203,7 @@ class ShapeRenderer: NodeRenderer { var outerCenter = CGPoint(x: CGFloat(gradient.cx), y: CGFloat(gradient.cy)) var radius = CGFloat(gradient.r) if !gradient.userSpace { - var bounds = ctx!.pathBounds + var bounds = ctx!.boundingBoxOfPath var scaleX: CGFloat = 1 var scaleY: CGFloat = 1 if bounds.width > bounds.height { @@ -212,7 +212,7 @@ class ShapeRenderer: NodeRenderer { scaleX = bounds.width / bounds.height } ctx!.scaleBy(x: scaleX, y: scaleY) - bounds = ctx!.pathBounds + bounds = ctx!.boundingBoxOfPath innerCenter = CGPoint(x: innerCenter.x * bounds.width + bounds.minX, y: innerCenter.y * bounds.height + bounds.minY) outerCenter = CGPoint(x: outerCenter.x * bounds.width + bounds.minX, y: outerCenter.y * bounds.height + bounds.minY) radius = min(radius * bounds.width, radius * bounds.height) diff --git a/Source/utils/BoundsUtils.swift b/Source/utils/BoundsUtils.swift index c34d6bfc..61ee5570 100644 --- a/Source/utils/BoundsUtils.swift +++ b/Source/utils/BoundsUtils.swift @@ -84,12 +84,3 @@ final internal class BoundsUtils { return copy } } - -extension CGContext { - var pathBounds: CGRect { - if let path = self.path { - return path.boundingBoxOfPath - } - return boundingBoxOfPath - } -}