Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Last active October 6, 2024 00:55
Show Gist options
  • Save amosgyamfi/7781ec254a4d0d6892d776f6a2bb0505 to your computer and use it in GitHub Desktop.
Save amosgyamfi/7781ec254a4d0d6892d776f6a2bb0505 to your computer and use it in GitHub Desktop.
//
// ThreadsLogoDrawing.swift
// CoreSwiftUI
import SwiftUI
struct ThreadsLogoPath: 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.33491*width, y: 0.38369*height))
path.addCurve(to: CGPoint(x: 0.68975*width, y: 0.51762*height), control1: CGPoint(x: 0.44602*width, y: 0.30482*height), control2: CGPoint(x: 0.67254*width, y: 0.22119*height))
path.addCurve(to: CGPoint(x: 0.34932*width, y: 0.60268*height), control1: CGPoint(x: 0.71125*width, y: 0.88816*height), control2: CGPoint(x: 0.28173*width, y: 0.79911*height))
path.addCurve(to: CGPoint(x: 0.79556*width, y: 0.51762*height), control1: CGPoint(x: 0.39233*width, y: 0.47768*height), control2: CGPoint(x: 0.56975*width, y: 0.41941*height))
path.addCurve(to: CGPoint(x: 0.61275*width, y: 0.94196*height), control1: CGPoint(x: 1.02136*width, y: 0.61583*height), control2: CGPoint(x: 0.84409*width, y: 0.90179*height))
path.addCurve(to: CGPoint(x: 0.07685*width, y: 0.38369*height), control1: CGPoint(x: 0.39073*width, y: 0.98053*height), control2: CGPoint(x: -0.05218*width, y: 0.93726*height))
path.addCurve(to: CGPoint(x: 0.93171*width, y: 0.38369*height), control1: CGPoint(x: 0.20588*width, y: -0.16987*height), control2: CGPoint(x: 1.02138*width, y: 0.05803*height))
return path
}
}
struct ThreadsLogoDrawing: View {
var body: some View {
ZStack {
ThreadsLogoPath()
.stroke(.quaternary, style: StrokeStyle(lineWidth: 32))
.phaseAnimator([1, 0]) { threadsLogo, draw in
ZStack {
threadsLogo
ThreadsLogoPath()
.trim(from: 0.0, to: draw)
.stroke(.white, style: StrokeStyle(lineWidth: 32))
}
} animation: { draw in
.linear(duration: 0.8).delay(0.5)
}
}
.scaleEffect(0.2)
}
}
#Preview {
ThreadsLogoDrawing()
.preferredColorScheme(.dark)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment