Skip to content

Instantly share code, notes, and snippets.

@CodeSlicing
Created October 8, 2021 09:23
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 CodeSlicing/7865ea405cd23f6ef538ddeefaac8da3 to your computer and use it in GitHub Desktop.
Save CodeSlicing/7865ea405cd23f6ef538ddeefaac8da3 to your computer and use it in GitHub Desktop.
Source code for original PureSwiftUIDesign logo
//
// PureSwiftUIDesignLogo.swift
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright © 2020 Adam Fordyce. All rights reserved.
//
import PureSwiftUI
struct PureSwiftUIDesignLogo: View {
var body: some View {
ZStack {
Color.clear
.layoutGuide(PureSwiftUIDesignSwiftLogoLayoutConfig, lineWidth: 1, opacity: 1)
.overlay(LinearGradient([(Color(#colorLiteral(red: 0.001801434788, green: 0.09054573625, blue: 0.5820378065, alpha: 1)), 0), (Color(#colorLiteral(red: 0, green: 1, blue: 1, alpha: 1)), 1)], to: .topLeading).blendMode(.multiply))
PureSwiftUIDesignSwiftLogo(debug: false)
.fill(Color.white)
.overlay(PureSwiftUIDesignSwiftLogo(debug: false)
.fill(Color.white(0.3))
.overlay(
PureSwiftUIDesignSwiftLogo(debug: false).fill(Color.white).blur(10)).drawingGroup().blendMode(.multiply))
PureSwiftUIDesignSwiftLogo(debug: true)
.stroke(Color.black, style: .init(lineWidth: 2, lineCap: .round, lineJoin: .round))
}
.clipRoundedRectangleWithStroke(50, .black, lineWidth: 2)
.showLayoutGuides(true)
}
}
private let PureSwiftUIDesignSwiftLogoLayoutConfig = LayoutGuideConfig.grid(
columns: [0, 0.052, 0.135, 0.246, 0.493, 0.54, 0.56, 0.605, 0.681, 0.81, 0.871, 0.937, 1],
rows: [0, 0.107, 0.182, 0.227, 0.493, 0.53, 0.619, 0.66, 0.676, 0.818, 0.894, 1])
private struct PureSwiftUIDesignSwiftLogo: Shape {
let debug: Bool
func path(in rect: CGRect) -> Path {
Path { path in
let g = PureSwiftUIDesignSwiftLogoLayoutConfig.layout(in: rect)
path.move(g[11, 10])
path.curve(g[9, 9], cp1: g[11, 10], cp2: g[rel: 0.9, 9], showControlPoints: debug)
path.curve(g[6, 10], cp1: g[rel: 0.75, 9], cp2: g[8, 10], showControlPoints: debug)
path.quadCurve(g[1, 6], cp: g[rel: 0.23, 10], showControlPoints: debug)
path.quadCurve(g[6, 8], cp: g[rel: 0.35, rel: 0.79], showControlPoints: debug)
path.quadCurve(g[2, 3], cp: g[rel: 0.41, rel: 0.58], showControlPoints: debug)
path.quadCurve(g[4, 4], cp: g[rel: 0.33, rel: 0.4], showControlPoints: debug)
path.quadCurve(g[3, 2], cp: g[rel: 0.4, rel: 0.4], showControlPoints: debug)
path.quadCurve(g[8, 5], cp: g[rel: 0.48, rel: 0.4], showControlPoints: debug)
path.quadCurve(g[7, 1], cp: g[rel: 0.76, rel: 0.31], showControlPoints: debug)
path.quadCurve(g[10, 7], cp: g[rel: 0.97, rel: 0.36], showControlPoints: debug)
path.quadCurve(g[11, 10], cp: g[rel: 0.98, rel: 0.8], showControlPoints: debug)
path.closeSubpath()
}
}
}
struct PureSwiftUIDesignLogo_Previews: PreviewProvider {
struct PureSwiftUIDesignLogo_Harness: View {
var body: some View {
PureSwiftUIDesignLogo()
.frame(400)
}
}
static var previews: some View {
PureSwiftUIDesignLogo_Harness()
.padding(50)
.previewSizeThatFits()
.previewDevice(.iPhone_12_Pro_Max)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment