Skip to content

Rendered SwiftUI doesn't match rendered SVG #26

@coughski

Description

@coughski

SVG render
Screenshot 2023-01-08 at 7 02 43 PM

SwiftUI render
Screenshot 2023-01-08 at 7 04 04 PM

SVG

<svg viewBox="0 0 280 280">
<path d="M 157 180.611 V 199 h 4 c 17.491 0 33.525 6.237 46 16.608 V 92 c 0 -40.87 -33.131 -74 -74 -74 -40.87 0 -74 33.13 -74 74 v 183.716 c 13.57 -1.94 24 -13.61 24 -27.716 v -45.577 A 71.952 71.952 0 0 1 105 199 h 4 v -18.389 a 56.236 56.236 0 0 1 -26 -25.365 v -61.98 c 9.147 -2.975 18.778 -7.249 28.342 -12.77 15.403 -8.894 28.089 -19.555 36.724 -30.099 a 86.935 86.935 0 0 0 7.044 15.488 c 8.768 15.185 21.114 26.349 33.89 32.032 v .249 c .4 .067 .794 .154 1.18 .26 .774 .323 1.55 .626 2.326 .91 A 11.998 11.998 0 0 1 199 110 v 13 c 0 6.019 -4.431 11.002 -10.209 11.867 -1.743 20.248 -14.26 37.416 -31.791 45.744 z"/>
</svg>

SwiftUI

struct MyCustomShape: Shape {
                func path(in rect: CGRect) -> Path {
                    var path = Path()
                    let width = rect.size.width
                    let height = rect.size.height
                    path.move(to: CGPoint(x: 0.56071*width, y: 0.64504*height))
                    path.addLine(to: CGPoint(x: 0.56071*width, y: 0.71071*height))
                    path.addLine(to: CGPoint(x: 0.575*width, y: 0.71071*height))
                    path.addCurve(to: CGPoint(x: 0.73929*width, y: 0.77003*height), control1: CGPoint(x: 0.63747*width, y: 0.71071*height), control2: CGPoint(x: 0.69473*width, y: 0.73299*height))
                    path.addLine(to: CGPoint(x: 0.73929*width, y: 0.32857*height))
                    path.addCurve(to: CGPoint(x: 0.475*width, y: 0.06429*height), control1: CGPoint(x: 0.73929*width, y: 0.18261*height), control2: CGPoint(x: 0.62096*width, y: 0.06429*height))
                    path.addCurve(to: CGPoint(x: 0.21071*width, y: 0.32857*height), control1: CGPoint(x: 0.32904*width, y: 0.06429*height), control2: CGPoint(x: 0.21071*width, y: 0.18261*height))
                    path.addLine(to: CGPoint(x: 0.21071*width, y: 0.9847*height))
                    path.addCurve(to: CGPoint(x: 0.29643*width, y: 0.88571*height), control1: CGPoint(x: 0.25918*width, y: 0.97777*height), control2: CGPoint(x: 0.29643*width, y: 0.93609*height))
                    path.addLine(to: CGPoint(x: 0.29643*width, y: 0.72294*height))
                    path.addLine(to: CGPoint(x: 0.38929*width, y: 0))
                    path.addLine(to: CGPoint(x: 0.38929*width, y: 0.64504*height))
                    path.addLine(to: CGPoint(x: 0, y: 0.33309*height))
                    path.addCurve(to: CGPoint(x: 0.39765*width, y: 0.28749*height), control1: CGPoint(x: 0.3291*width, y: 0.32247*height), control2: CGPoint(x: 0.36349*width, y: 0.3072*height))
                    path.addCurve(to: CGPoint(x: 0.52881*width, y: 0.17999*height), control1: CGPoint(x: 0.45266*width, y: 0.25572*height), control2: CGPoint(x: 0.49797*width, y: 0.21765*height))
                    path.addCurve(to: CGPoint(x: 0.675*width, y: 0.3497*height), control1: CGPoint(x: 0.58528*width, y: 0.28954*height), control2: CGPoint(x: 0.62937*width, y: 0.32941*height))
                    path.addLine(to: CGPoint(x: 0.675*width, y: 0.35059*height))
                    path.addCurve(to: CGPoint(x: 0.67921*width, y: 0.35152*height), control1: CGPoint(x: 0.67643*width, y: 0.35083*height), control2: CGPoint(x: 0.67784*width, y: 0.35114*height))
                    path.addCurve(to: CGPoint(x: 0.68752*width, y: 0.35477*height), control1: CGPoint(x: 0.68198*width, y: 0.35267*height), control2: CGPoint(x: 0.68475*width, y: 0.35376*height))
                    path.addLine(to: CGPoint(x: 0, y: 0.43929*height))
                    path.addCurve(to: CGPoint(x: 0.67425*width, y: 0.48167*height), control1: CGPoint(x: 0.71071*width, y: 0.46078*height), control2: CGPoint(x: 0.69489*width, y: 0.47858*height))
                    path.addCurve(to: CGPoint(x: 0.56071*width, y: 0.64504*height), control1: CGPoint(x: 0.66803*width, y: 0.55398*height), control2: CGPoint(x: 0.62333*width, y: 0.6153*height))
                    path.closeSubpath()
                    return path
                }
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions