Created
May 19, 2024 12:44
-
-
Save amosgyamfi/bba990bda880034decea8c20a2d77927 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SquareInfinitySymbol.swift | |
// OpenSwiftUIAnimations | |
// | |
// Created by Amos Gyamfi on 12.5.2024. | |
// | |
import SwiftUI | |
struct SquareInfinitySymbol: View { | |
let streamBlue = Color(#colorLiteral(red: 0, green: 0.3725490196, blue: 1, alpha: 1)) | |
let streamRed = Color(#colorLiteral(red: 1, green: 0, blue: 0, alpha: 1)) | |
var body: some View { | |
ZStack { | |
Text("Infinity view") | |
.phaseAnimator([false, true]) { openPath, moveAround in | |
Path { path in | |
path.addLines([ | |
.init(x: 2, y: 1), | |
.init(x: 1, y: 0), | |
.init(x: 0, y: 1), | |
.init(x: 1, y: 2), | |
.init(x: 3, y: 0), | |
.init(x: 4, y: 1), | |
.init(x: 3, y: 2), | |
.init(x: 2, y: 1) | |
]) | |
} | |
//.trim(from: 0.25, to: 1.0) | |
.scale(10, anchor: .topLeading) | |
.stroke(LinearGradient(gradient: Gradient(colors: [streamBlue, streamRed]), startPoint: .leading, endPoint: .trailing), style: StrokeStyle( | |
lineWidth: 4, | |
lineCap: .round, | |
lineJoin: .round, | |
miterLimit: 0, dash: [100, 15], | |
dashPhase: moveAround ? 100 : -225)) | |
.offset(x: UIScreen.main.bounds.width/2.15, y: UIScreen.main.bounds.height/2.3) | |
} animation: { moveAround in | |
.linear.speed(0.05).repeatForever(autoreverses: false) | |
} | |
} | |
} | |
} | |
#Preview { | |
SquareInfinitySymbol() | |
.preferredColorScheme(.dark) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment