TokamakUI / Tokamak

SwiftUI-compatible framework for building browser apps with WebAssembly and native apps for other platforms
Apache License 2.0
2.62k stars 111 forks source link

Rect received in custom shape path in rect is always zero #549

Open shial4 opened 1 year ago

shial4 commented 1 year ago

Describe the bug rect is always zero path(in rect: CGRect) in size

To Reproduce

public struct Arrow: Shape {
    public init() {}

    public func path(in rect: CGRect) -> Path {
        print("🅰️", rect)
        return Path { path in
            path.move(to: CGPoint(x: 0, y: rect.height * 0.3))
            path.addLine(to: CGPoint(x: 0, y: rect.height * 0.7))
            path.addLine(to: CGPoint(x: rect.width * 0.6, y: rect.height * 0.6))
            path.addLine(to: CGPoint(x: rect.width * 0.6, y: rect.height * 0.8))
            path.addLine(to: CGPoint(x: rect.width, y: rect.height / 2))
            path.addLine(to: CGPoint(x: rect.width * 0.6, y: rect.height * 0.2 ))
            path.addLine(to: CGPoint(x: rect.width * 0.6, y: rect.height * 0.4 ))
            path.closeSubpath()
        }
    }
}

Expected behavior Rect has the size of the content.