import AppKit // Draws the Konverter icon: a warm tangerine squircle with a radial conversion // wheel on it. Everything is vector-drawn so the script has no dependencies. let canvas: CGFloat = 1024 let size = NSSize(width: canvas, height: canvas) guard let rep = NSBitmapImageRep( bitmapDataPlanes: nil, pixelsWide: Int(canvas), pixelsHigh: Int(canvas), bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0 ) else { exit(1) } NSGraphicsContext.saveGraphicsState() NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep) NSGraphicsContext.current?.imageInterpolation = .high let rect = NSRect(origin: .zero, size: size) // macOS icons live inside a ~10% margin; the squircle fills the rest. let body = rect.insetBy(dx: 96, dy: 96) let squircle = NSBezierPath(roundedRect: body, xRadius: 200, yRadius: 200) let gradient = NSGradient(colors: [ NSColor(calibratedRed: 1.00, green: 0.66, blue: 0.20, alpha: 1), NSColor(calibratedRed: 0.94, green: 0.33, blue: 0.11, alpha: 1), ])! gradient.draw(in: squircle, angle: -60) // Soft top highlight. NSGraphicsContext.saveGraphicsState() squircle.addClip() NSGradient(colors: [ NSColor.white.withAlphaComponent(0.28), NSColor.white.withAlphaComponent(0.00), ])!.draw(in: NSRect(x: body.minX, y: body.midY, width: body.width, height: body.height / 2), angle: -90) NSGraphicsContext.restoreGraphicsState() // Radial wheel: eight segments, one of them highlighted as the selection. let center = NSPoint(x: rect.midX, y: rect.midY + 24) let outer: CGFloat = 296 let inner: CGFloat = 150 let segmentCount = 8 let gap: CGFloat = 3.2 func polar(_ radius: CGFloat, _ degrees: CGFloat) -> NSPoint { let radians = degrees * .pi / 180 return NSPoint(x: center.x + radius * cos(radians), y: center.y + radius * sin(radians)) } func segment(_ index: Int, from start: CGFloat, to end: CGFloat) -> NSBezierPath { let path = NSBezierPath() path.move(to: polar(inner, start)) path.line(to: polar(outer, start)) path.appendArc(withCenter: center, radius: outer, startAngle: start, endAngle: end) path.line(to: polar(inner, end)) path.appendArc(withCenter: center, radius: inner, startAngle: end, endAngle: start, clockwise: true) path.close() return path } for index in 0..= 2 else { exit(1) } guard let data = rep.representation(using: .png, properties: [:]) else { exit(1) } do { try data.write(to: URL(fileURLWithPath: CommandLine.arguments[1])) } catch { exit(1) }