Repository Public License
1// ORIX Clean — Scripts/dmg-background.swift2// Description: Draws the disk-image background (660×420 pt at 2x): brand gradient, title and a drag arrow.3// Author: Simon-Pierre Boucher — contact@spboucher.ai4import AppKit56let out = CommandLine.arguments.count > 1 ? CommandLine.arguments[1] : "dmg-background.png"7let w = 1320, h = 8408let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: w, pixelsHigh: h, bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,9 colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!10rep.size = NSSize(width: 660, height: 420)11NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)12NSGradient(colors: [NSColor(srgbRed: 0.07, green: 0.09, blue: 0.17, alpha: 1), NSColor(srgbRed: 0.03, green: 0.04, blue: 0.09, alpha: 1)])!13 .draw(in: NSRect(x: 0, y: 0, width: 660, height: 420), angle: -90)14NSGradient(colors: [NSColor(srgbRed: 0.18, green: 0.83, blue: 0.75, alpha: 0.22), .clear])!15 .draw(fromCenter: NSPoint(x: 330, y: 215), radius: 0, toCenter: NSPoint(x: 330, y: 215), radius: 330, options: [])16func text(_ s: String, _ size: CGFloat, _ weight: NSFont.Weight, _ alpha: CGFloat, y: CGFloat) {17 let p = NSMutableParagraphStyle(); p.alignment = .center18 NSAttributedString(string: s, attributes: [.font: NSFont.systemFont(ofSize: size, weight: weight), .foregroundColor: NSColor(white: 1, alpha: alpha), .paragraphStyle: p])19 .draw(in: NSRect(x: 0, y: y, width: 660, height: size * 1.5))20}21text("ORIX Clean", 26, .bold, 0.96, y: 345)22text("Reclaim Space. Keep Control.", 13, .regular, 0.6, y: 322)23text("Drag ORIX Clean to the Applications folder", 13, .medium, 0.75, y: 62)24let arrow = NSBezierPath()25arrow.move(to: NSPoint(x: 285, y: 215)); arrow.line(to: NSPoint(x: 372, y: 215))26arrow.move(to: NSPoint(x: 358, y: 229)); arrow.line(to: NSPoint(x: 374, y: 215)); arrow.line(to: NSPoint(x: 358, y: 201))27arrow.lineWidth = 5; arrow.lineCapStyle = .round; arrow.lineJoinStyle = .round28NSColor(srgbRed: 0.37, green: 0.92, blue: 0.83, alpha: 0.9).setStroke(); arrow.stroke()29try! rep.representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: out))30