Hi all.
Task: To make one-forth of the circle fully transparent.All of the space within the black triangle must be invisible.
Optional task: It could be great to put the entire triangle in the circle.I mean the apex is too high.
The repository below is for your convenience.
https://github.com/Denis411/For-the-community..git
Pure code:
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack{
MyArc()
.fill(LinearGradient(gradient: Gradient(colors: [.green, .yellow, .orange, .red,]), startPoint: .bottom, endPoint: .top ))
Triangle()
.clipped()
.opacity(0.74)
}
}
}
struct MyArc: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.addArc(center: CGPoint(x: rect.midX, y: rect.midY),
radius: rect.size.width / 2,
startAngle: .degrees(0),
endAngle: .degrees(275),
clockwise: false)
return path
}
}
struct Triangle: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: CGPoint(x: rect.midX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.midX, y: rect.midY))
path.addLine(to: CGPoint(x: rect.maxX, y: rect.midY))
return path
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Thanks for your priceless time.