룰렛 뷰 추가
This commit is contained in:
38
SodaLive/Sources/FortuneWheel/SpinWheelCell.swift
Normal file
38
SodaLive/Sources/FortuneWheel/SpinWheelCell.swift
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// SpinWheelCell.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/12/07.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SpinWheelCell: Shape {
|
||||
|
||||
let startAngle: Double, endAngle: Double
|
||||
|
||||
func path(in rect: CGRect) -> Path {
|
||||
var path = Path()
|
||||
let radius = min(rect.width, rect.height) / 2
|
||||
let alpha = CGFloat(startAngle)
|
||||
let center = CGPoint(
|
||||
x: rect.midX,
|
||||
y: rect.midY
|
||||
)
|
||||
path.move(to: center)
|
||||
path.addLine(
|
||||
to: CGPoint(
|
||||
x: center.x + cos(alpha) * radius,
|
||||
y: center.y + sin(alpha) * radius
|
||||
)
|
||||
)
|
||||
path.addArc(
|
||||
center: center, radius: radius,
|
||||
startAngle: Angle(radians: startAngle),
|
||||
endAngle: Angle(radians: endAngle),
|
||||
clockwise: false
|
||||
)
|
||||
path.closeSubpath()
|
||||
return path
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user