Skip to content

Instantly share code, notes, and snippets.

@mattyoung
Last active October 23, 2023 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyoung/af033cf1a9bd556cf56904f1d4855cc1 to your computer and use it in GitHub Desktop.
Save mattyoung/af033cf1a9bd556cf56904f1d4855cc1 to your computer and use it in GitHub Desktop.
//
// BricsLogo.swift
// iOS17-New-Beginning
//
// Created by Matthew Young on 10/22/23.
//
import SwiftUI
extension ShapeStyle where Self == LinearGradient {
static var rainbow: Self { LinearGradient(
gradient: .init(colors: repeatElement([Color.red, .orange, .yellow, .green, .blue, .purple, .red, .init(red: 127.0 / 255, green: 0, blue: 1)], count: 2).flatMap {
$0
}),
startPoint: .leading,
endPoint: .trailing
)
}
}
struct BricsLogo: View {
@ViewBuilder
func lettering<S: ShapeStyle>(
flag: String,
letter: String,
alignment: Alignment = .center,
style: S = .rainbow
) -> some View {
// let font = "Verdana Bold"
let font = "Baskerville Bold Italic"
let fontSize = 120.0
let flagOverSize = fontSize * 1.0
Text(letter)
.font(.custom(font, size: fontSize, relativeTo: .largeTitle))
.foregroundStyle(style)
.overlay(
Text(flag)
.font(.custom(font, size: flagOverSize, relativeTo: .largeTitle))
.mask(alignment: alignment, { Text(letter) })
.font(.custom(font, size: fontSize, relativeTo: .largeTitle))
.innerShadow(2)
.shadow(2, offset: .init(2, 2))
)
}
var body: some View {
HStack(spacing: -5) {
lettering(flag: "🇧🇷", letter: "B")
lettering(flag: "🇷🇺", letter: "R")
lettering(flag: "🇮🇳", letter: "I")
lettering(flag: "🇨🇳", letter: "C")
lettering(flag: "🇿🇦", letter: "S")
}
.padding(.init(50, 30))
.background(
UnevenRoundedRectangle(
topLeadingRadius: 0,
bottomLeadingRadius: 50,
bottomTrailingRadius: 50,
topTrailingRadius: 50,
style: .continuous
)
.foregroundStyle(.mint.gradient)
)
}
}
#Preview {
BricsLogo()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment