Repository Public
1// ORIX DJ2// File: Scripts/dmg-background.swift3// Description: Draws the disk-image background (660×420 pt at 2x): brand gradient, title and a drag arrow.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import AppKit89let out = CommandLine.arguments.count > 1 ? CommandLine.arguments[1] : "dmg-background.png"10let w = 1320, h = 84011let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: w, pixelsHigh: h, bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,12 colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!13rep.size = NSSize(width: 660, height: 420)14NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)15NSGradient(colors: [NSColor(srgbRed: 0.10, green: 0.13, blue: 0.26, alpha: 1), NSColor(srgbRed: 0.03, green: 0.04, blue: 0.09, alpha: 1)])!16 .draw(in: NSRect(x: 0, y: 0, width: 660, height: 420), angle: -90)17NSGradient(colors: [NSColor(srgbRed: 0.49, green: 0.36, blue: 0.99, alpha: 0.24), .clear])!18 .draw(fromCenter: NSPoint(x: 330, y: 215), radius: 0, toCenter: NSPoint(x: 330, y: 215), radius: 330, options: [])19func text(_ s: String, _ size: CGFloat, _ weight: NSFont.Weight, _ alpha: CGFloat, y: CGFloat) {20 let p = NSMutableParagraphStyle(); p.alignment = .center21 NSAttributedString(string: s, attributes: [.font: NSFont.systemFont(ofSize: size, weight: weight), .foregroundColor: NSColor(white: 1, alpha: alpha), .paragraphStyle: p])22 .draw(in: NSRect(x: 0, y: y, width: 660, height: size * 1.5))23}24text("ORIX DJ", 26, .bold, 0.96, y: 345)25text("Mix the Music. Program the Experience.", 13, .regular, 0.6, y: 322)26text("Drag ORIX DJ to the Applications folder", 13, .medium, 0.75, y: 62)27let arrow = NSBezierPath()28arrow.move(to: NSPoint(x: 285, y: 215)); arrow.line(to: NSPoint(x: 372, y: 215))29arrow.move(to: NSPoint(x: 358, y: 229)); arrow.line(to: NSPoint(x: 374, y: 215)); arrow.line(to: NSPoint(x: 358, y: 201))30arrow.lineWidth = 5; arrow.lineCapStyle = .round; arrow.lineJoinStyle = .round31NSColor(srgbRed: 0.61, green: 0.49, blue: 1.0, alpha: 0.95).setStroke(); arrow.stroke()32try! rep.representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: out))33