Created
August 1, 2023 01:44
-
-
Save YusukeHosonuma/31b507a94c394126bb6cc94bcb62eeed to your computer and use it in GitHub Desktop.
SwiftUI: The Laughing Man(笑い男)のロゴ
This file contains hidden or 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
import SwiftUI | |
import Algorithms | |
struct ContentView: View { | |
@State var angle: Double = 0 | |
var body: some View { | |
TimelineView(.animation()) { time in | |
Waraiotoko(angle: angle) | |
.onChange(of: time.date) { _, _ in | |
angle += 0.8 | |
} | |
} | |
} | |
} | |
struct Waraiotoko: View { | |
var angle: Double | |
let text: String = "I thought what I'd do was, I'd pretend I was one of those deaf-mutes" | |
var body: some View { | |
ZStack { | |
ForEach(Array(text).indexed(), id: \.index) { index, c in | |
let degrees = Double(index * (360 / text.count)) + 102 + angle | |
Text("\(String(c))") | |
.foregroundStyle(.blue) | |
.offset(y: -130) | |
.rotationEffect(.degrees(degrees)) | |
} | |
Circle() | |
.stroke(.blue, lineWidth: 6) | |
.frame(width: 290) | |
Circle() | |
.stroke(.blue, lineWidth: 12) | |
.frame(width: 220) | |
Rectangle() | |
.frame(width: 16, height: 12) | |
.foregroundStyle(.blue) | |
.offset(y: -114) | |
Rectangle() | |
.frame(width: 270, height: 12) | |
.foregroundStyle(.blue) | |
.offset(x: 25, y: -16) | |
Rectangle() | |
.frame(width: 50, height: 12) | |
.foregroundStyle(.blue) | |
.offset(x: 135, y: 16) | |
Circle() | |
.stroke(.blue, lineWidth: 12) | |
.frame(width: 32) | |
.offset(x: 160) | |
Rectangle() | |
.frame(width: 60, height: 20) | |
.foregroundStyle(.white) | |
.offset(x: 130, y: 0) | |
Rectangle() | |
.frame(width: 14, height: 6) | |
.foregroundStyle(.white) | |
.offset(x: -110, y: -7) | |
eye() | |
.offset(x: -40, y: 8) | |
eye() | |
.offset(x: 40, y: 8) | |
Path { path in | |
path.addArc( | |
center: CGPoint(x: 50, y: 0), | |
radius: 80, | |
startAngle: .degrees(12), | |
endAngle: .degrees(168), | |
clockwise: false | |
) | |
path.closeSubpath() | |
} | |
.stroke(lineWidth: 12) | |
.fill(.blue) | |
.frame(width: 200, height: 200) | |
.offset(x: 50, y: 100) | |
} | |
.font(.custom("Impact", size: 20)) | |
.monospaced() | |
.fontWeight(.bold) | |
.padding() | |
} | |
func eye() -> some View { | |
Group { | |
Circle() | |
.fill(.blue) | |
.frame(width: 32) | |
Circle() | |
.fill(.white) | |
.frame(width: 40) | |
.offset(y: 12) | |
} | |
} | |
} | |
#Preview { | |
ContentView(angle: 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment