Skip to content

Instantly share code, notes, and snippets.

@0rientd
Created July 1, 2021 15:20
Show Gist options
  • Save 0rientd/5b62e7c83a4bcaca56a83ed282e1346d to your computer and use it in GitHub Desktop.
Save 0rientd/5b62e7c83a4bcaca56a83ed282e1346d to your computer and use it in GitHub Desktop.
Animation circle blurred with SwiftUI
//
// ContentView.swift
// blurLogo
//
// Created by 0rientd on 29/06/21.
//
import SwiftUI
struct ContentView: View {
@State private var blurRadius = 0
@State private var movementBlue = 130
@State private var movementRed = 130
@State private var opacityText = 0.0
@State private var shadowCircle = 0
@State private var finalOpacity = 1.0
var body: some View {
ZStack {
Color.black
.ignoresSafeArea()
.onAppear() {
withAnimation(.easeInOut(duration: 2)) {
self.blurRadius = 15
self.opacityText = 1.0
self.shadowCircle = 10
self.finalOpacity = 0.6
}
withAnimation(.easeInOut(duration: 0.9).repeatForever(autoreverses: true)) {
self.movementBlue = -130
self.movementRed = -130
}
}
Circle()
.fill(
Color.red
)
.frame(width: 150, height: 150, alignment: .center)
.padding(.trailing, CGFloat(self.movementRed))
.blur(radius: CGFloat(self.blurRadius))
.opacity(self.finalOpacity)
Circle()
.fill(
Color.blue
)
.frame(width: 150, height: 150, alignment: .center)
.padding(.leading, CGFloat(self.movementBlue))
.blur(radius: CGFloat(self.blurRadius))
.opacity(self.finalOpacity)
Circle()
.fill(
Color.purple
)
.frame(width: 150, height: 150, alignment: .center)
.blur(radius: CGFloat(self.blurRadius))
.shadow(radius: CGFloat(self.shadowCircle))
.shadow(radius: CGFloat(self.shadowCircle))
Text("dev.0rientd")
.opacity(self.opacityText)
.foregroundColor(.white)
.font(.system(size: 20))
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment