hop
Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key.
Brought by drakestapleton
| 1 | // Draws Hop's app icon (no outside tools): `swift tools/make-icon.swift <out.png>` then build.sh packs it. |
| 2 | // Four colours: background, action fill, accent, white. |
| 3 | import AppKit |
| 4 | |
| 5 | let out = CommandLine.arguments[1] |
| 6 | let S: CGFloat = 1024 |
| 7 | let cs = CGColorSpace(name: CGColorSpace.sRGB)! |
| 8 | let ctx = CGContext(data: nil, width: Int(S), height: Int(S), bitsPerComponent: 8, bytesPerRow: 0, space: cs, |
| 9 | bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)! |
| 10 | func rgb(_ hex: UInt32, _ a: CGFloat = 1) -> CGColor { |
| 11 | CGColor(colorSpace: cs, components: [CGFloat((hex >> 16) & 0xff) / 255, CGFloat((hex >> 8) & 0xff) / 255, CGFloat(hex & 0xff) / 255, a])! |
| 12 | } |
| 13 | let bgPrimary: UInt32 = 0x0a0a0f, accentFill: UInt32 = 0x2563eb, accent: UInt32 = 0x63b3ed, white: UInt32 = 0xffffff |
| 14 | |
| 15 | // macOS icon tile: 824 pt square, continuous-looking corner, centred on a 1024 canvas. |
| 16 | let tile = CGRect(x: 100, y: 100, width: 824, height: 824) |
| 17 | let shape = CGPath(roundedRect: tile, cornerWidth: 186, cornerHeight: 186, transform: nil) |
| 18 | ctx.addPath(shape); ctx.clip() |
| 19 | ctx.setFillColor(rgb(bgPrimary)); ctx.fill(tile) |
| 20 | |
| 21 | // Where the hop lands. Ripples spread from that one point (space motif: accent at 4 to 22 percent). |
| 22 | let land = CGPoint(x: 668, y: 372), start = CGPoint(x: 300, y: 372) |
| 23 | for (i, a) in [0.22, 0.17, 0.12, 0.08, 0.05].enumerated() { |
| 24 | let r = CGFloat(150 + i * 96) |
| 25 | ctx.setStrokeColor(rgb(accent, a)); ctx.setLineWidth(6) |
| 26 | ctx.strokeEllipse(in: CGRect(x: land.x - r, y: land.y - r, width: r * 2, height: r * 2)) |
| 27 | } |
| 28 | // A few small stars. |
| 29 | for (x, y, r, a) in [(238.0, 760.0, 5.0, 0.6), (420.0, 838.0, 3.5, 0.4), (792.0, 800.0, 4.5, 0.5), (850.0, 640.0, 3.0, 0.35), (188.0, 560.0, 3.0, 0.3)] { |
| 30 | ctx.setFillColor(rgb(white, a)); ctx.fillEllipse(in: CGRect(x: x - r, y: y - r, width: r * 2, height: r * 2)) |
| 31 | } |
| 32 | // The hop: one clean arc from where you are to where you want to be. |
| 33 | let arc = CGMutablePath() |
| 34 | arc.move(to: start) |
| 35 | arc.addCurve(to: land, control1: CGPoint(x: 340, y: 760), control2: CGPoint(x: 628, y: 760)) |
| 36 | ctx.addPath(arc); ctx.setStrokeColor(rgb(white)); ctx.setLineWidth(58); ctx.setLineCap(.round); ctx.strokePath() |
| 37 | // Take-off point (quiet) and landing point (the one action colour). |
| 38 | ctx.setFillColor(rgb(white)); ctx.fillEllipse(in: CGRect(x: start.x - 29, y: start.y - 29, width: 58, height: 58)) |
| 39 | ctx.setFillColor(rgb(bgPrimary)); ctx.fillEllipse(in: CGRect(x: land.x - 96, y: land.y - 96, width: 192, height: 192)) |
| 40 | ctx.setFillColor(rgb(accentFill)); ctx.fillEllipse(in: CGRect(x: land.x - 76, y: land.y - 76, width: 152, height: 152)) |
| 41 | // Hairline edge instead of a shadow. |
| 42 | ctx.resetClip(); ctx.addPath(shape); ctx.setStrokeColor(rgb(white, 0.10)); ctx.setLineWidth(3); ctx.strokePath() |
| 43 | |
| 44 | let rep = NSBitmapImageRep(cgImage: ctx.makeImage()!) |
| 45 | try! rep.representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: out)) |