Skip to content

Commit 9af8f5e

Browse files
committed
Update Radius
1 parent 20190f9 commit 9af8f5e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

SwiftDraw/LayerTree.Builder.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,14 @@ extension LayerTree.Builder {
260260
return nil
261261
}
262262

263+
let cx = element.cx ?? 0.5
264+
let cy = element.cy ?? 0.5
265+
263266
return LayerTree.RadialGradient(
264267
gradient: gradient,
265-
center: LayerTree.Point(element.fx ?? element.cx ?? 0.5, element.fy ?? element.cy ?? 0.5),
268+
center: LayerTree.Point(element.fx ?? cx, element.fy ?? cy),
266269
radius: LayerTree.Float(element.fr ?? 0),
267-
endCenter: LayerTree.Point(element.cx ?? 0.5, element.cy ?? 0.5),
270+
endCenter: LayerTree.Point(cx, cy),
268271
endRadius: LayerTree.Float(element.r ?? 0.5)
269272
)
270273
}

SwiftDraw/LayerTree.CommandGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ extension LayerTree {
235235
switch fillGradient.gradient.units {
236236
case .objectBoundingBox:
237237
let pathBounds = provider.getBounds(from: shape)
238-
let h = sqrt((pathBounds.width*pathBounds.width) + (pathBounds.height*pathBounds.height))
238+
let h = sqrt((pathBounds.width*pathBounds.width) + (pathBounds.height*pathBounds.height)) / 2
239239
startCenter = LayerTree.Point(
240240
pathBounds.x + (fillGradient.center.x * pathBounds.width),
241241
pathBounds.y + (fillGradient.center.y * pathBounds.height)

0 commit comments

Comments
 (0)