Open History to see the last commit
1import AppKit
2import ExpeditionCore
3
4@main enum JOLBrandRenderer {
5 @MainActor static func main() throws {
6 let (silhouette, eyes) = ExplorerRig.runningBrandArtwork()
7 let bounds = silhouette.boundingBoxOfPath
8 let scale = 65 / bounds.height
9 var transform = CGAffineTransform(
10 a: scale, b: 0, c: 0, d: -scale,
11 tx: 65 - bounds.midX * scale, ty: 75 + bounds.minY * scale
12 )
13 let runner = svgPath(silhouette.copy(using: &transform)!)
14 let expression = svgPath(eyes.copy(using: &transform)!)
15 let logo = """
16 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 248 84" role="img" aria-labelledby="title">
17 <title id="title">JOL — Jerry On Line</title>
18 <path d="M40 7Q42 4 44 7L81 68Q83 72 78 72H6Q2 72 4 68Z"
19 fill="#3257c7" stroke="#f8f3e0" stroke-width="2.6" stroke-linejoin="round"/>
20 <path d="M57 35C48 25 34 27 26 36C18 45 24 55 34 53C42 51 46 44 48 39"
21 fill="none" stroke="#f8f3e0" stroke-width="4" stroke-linecap="round"/>
22 <path d="\(runner)" fill="#ffda27" stroke="#172947" stroke-width="2.8" stroke-linejoin="round"/>
23 <path d="\(expression)" fill="#172947"/>
24 <g fill="#f8f3e0" transform="translate(11 0) skewX(-10)">
25 <path d="M110 18H145V48C145 62 138 68 123 68H116C102 68 96 62 96 49V45H109V49C109 54 112 56 117 56H123C130 56 132 53 132 48V30H110Z"/>
26 <path fill-rule="evenodd" d="M176 17C193 17 203 26 203 42C203 59 193 69 176 69C159 69 149 59 149 42C149 26 159 17 176 17ZM176 30C167 30 162 34 162 42C162 51 167 56 176 56C185 56 190 51 190 42C190 34 185 30 176 30Z"/>
27 <path d="M210 18H224V55H245V68H210Z"/>
28 </g>
29 </svg>
30 """
31 try logo.write(to: URL(fileURLWithPath: CommandLine.arguments[1]), atomically: true, encoding: .utf8)
32 }
33
34 private static func svgPath(_ path: CGPath) -> String {
35 func point(_ value: CGPoint) -> String {
36 String(format: "%.2f %.2f", locale: Locale(identifier: "en_US_POSIX"), value.x, value.y)
37 }
38 var commands: [String] = []
39 path.applyWithBlock { pointer in
40 let element = pointer.pointee
41 let points = element.points
42 switch element.type {
43 case .moveToPoint: commands.append("M" + point(points[0]))
44 case .addLineToPoint: commands.append("L" + point(points[0]))
45 case .addQuadCurveToPoint: commands.append("Q" + point(points[0]) + " " + point(points[1]))
46 case .addCurveToPoint: commands.append("C" + point(points[0]) + " " + point(points[1]) + " " + point(points[2]))
47 case .closeSubpath: commands.append("Z")
48 @unknown default: break
49 }
50 }
51 return commands.joined()
52 }
53}