Repository Public License
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : ORIX Monitor9// File : Scripts/tools/make-icon.swift10// Description : Draws the five ORIX Monitor icon concepts with Core11// Graphics and exports the chosen one at every macOS size.12// swift make-icon.swift concepts <dir> five 1024 px concepts13// + a contact sheet with 16–128 px renders swift14// make-icon.swift export <n> <dir> concept n as15// icon_<size>.png (16…1024)16// Module : Scripts17// Repository : https://git.spboucher.ai/orix-monitor18// Created : 2026-11-2119// Last Modified : 2026-11-2120//21// =============================================================================22// AUTHOR & PROFESSIONAL AFFILIATION23// =============================================================================24//25// Author : Simon-Pierre Boucher26// Position : Professor of Finance27// Institution : Université du Québec en Outaouais (UQO)28// Department : Département des sciences administratives29// Organization : SP Boucher30//31// Website : https://spboucher.ai32// Git : https://git.spboucher.ai33//34// =============================================================================35// OFFICIAL CONTACT DIRECTORY36// =============================================================================37//38// General : info@spboucher.ai39// Professional : contact@spboucher.ai40// Direct : simon@spboucher.ai41// Research : research@spboucher.ai42// Development : dev@spboucher.ai43// Support : support@spboucher.ai44// Security/Admin : admin@spboucher.ai45// Notifications : notifications@spboucher.ai46//47// Preferred Contact: support@spboucher.ai48//49// =============================================================================50// COPYRIGHT & INTELLECTUAL PROPERTY51// =============================================================================52//53// Copyright (c) 202654// Simon-Pierre Boucher55//56// All rights reserved where applicable.57//58// This file is governed by the applicable project license,59// copyright notices, institutional agreements and relevant law.60//61// Unless expressly authorized by the applicable license or62// rights holder, copying, redistribution, sublicensing,63// publication and commercial exploitation are not permitted.64//65// Existing third-party rights and notices remain unaffected.66//67// =============================================================================68// CONFIDENTIALITY & SECURITY69// =============================================================================70//71// Classification : Public72// Distribution : Public repository; use is governed by the project license73// Security Contact : admin@spboucher.ai74//75// Access to this source does not independently grant permission76// to redistribute or disclose confidential materials.77//78// Do not embed credentials, private keys, access tokens,79// certificates or confidential personal information.80//81// =============================================================================82// LICENSE & MAINTENANCE83// =============================================================================84//85// License : Proprietary, all rights reserved (see license file)86// License File : LICENSE87// Maintainer : Simon-Pierre Boucher88// Technical Contact: dev@spboucher.ai89//90// =============================================================================91// END OF SP BOUCHER SOURCE HEADER92// =============================================================================9394import AppKit95import CoreGraphics9697func rgb(_ hex: UInt32, _ a: CGFloat = 1) -> CGColor {98 CGColor(srgbRed: CGFloat((hex >> 16) & 0xFF) / 255, green: CGFloat((hex >> 8) & 0xFF) / 255, blue: CGFloat(hex & 0xFF) / 255, alpha: a)99}100let space = CGColorSpace(name: CGColorSpace.sRGB)!101func gradient(_ colors: [CGColor]) -> CGGradient { CGGradient(colorsSpace: space, colors: colors as CFArray, locations: nil)! }102let cyan: UInt32 = 0x22D3EE, indigo: UInt32 = 0x6366F1, violet: UInt32 = 0xA78BFA103104/// macOS icon grid: 824 pt plate centred in a 1024 canvas, continuous corners, soft drop shadow.105func plate(_ c: CGContext) -> CGRect {106 let rect = CGRect(x: 100, y: 100, width: 824, height: 824)107 let path = CGPath(roundedRect: rect, cornerWidth: 186, cornerHeight: 186, transform: nil)108 c.saveGState()109 c.setShadow(offset: CGSize(width: 0, height: -10), blur: 24, color: rgb(0x000000, 0.35))110 c.addPath(path)111 c.setFillColor(rgb(0x0A0D18))112 c.fillPath()113 c.restoreGState()114 c.saveGState()115 c.addPath(path)116 c.clip()117 c.drawLinearGradient(gradient([rgb(0x1D2440), rgb(0x0B0E1B)]), start: CGPoint(x: 512, y: 924), end: CGPoint(x: 512, y: 100), options: [])118 c.drawRadialGradient(gradient([rgb(cyan, 0.20), rgb(cyan, 0)]), startCenter: CGPoint(x: 300, y: 800), startRadius: 0, endCenter: CGPoint(x: 300, y: 800), endRadius: 620, options: [])119 c.restoreGState()120 c.addPath(CGPath(roundedRect: rect.insetBy(dx: 2, dy: 2), cornerWidth: 184, cornerHeight: 184, transform: nil))121 c.setStrokeColor(rgb(0xFFFFFF, 0.10))122 c.setLineWidth(4)123 c.strokePath()124 return rect125}126127/// Strokes a path with the cyan → indigo family gradient.128func strokeGradient(_ c: CGContext, _ path: CGPath, width: CGFloat, colors: [UInt32] = [cyan, indigo], from: CGPoint = CGPoint(x: 220, y: 780), to: CGPoint = CGPoint(x: 800, y: 240)) {129 c.saveGState()130 c.addPath(path)131 c.setLineWidth(width)132 c.setLineCap(.round)133 c.setLineJoin(.round)134 c.replacePathWithStrokedPath()135 c.clip()136 c.drawLinearGradient(gradient(colors.map { rgb($0) }), start: from, end: to, options: [.drawsBeforeStartLocation, .drawsAfterEndLocation])137 c.restoreGState()138}139140func pulse(from x0: CGFloat, to x1: CGFloat, y: CGFloat, amplitude a: CGFloat) -> CGPath {141 let p = CGMutablePath(), w = x1 - x0142 p.move(to: CGPoint(x: x0, y: y))143 for (fx, fy) in [(0.30, 0.0), (0.40, 0.95), (0.54, -1.0), (0.64, 0.42), (0.71, 0.0), (1.0, 0.0)] as [(CGFloat, CGFloat)] {144 p.addLine(to: CGPoint(x: x0 + w * fx, y: y + a * fy))145 }146 return p147}148149func concept(_ n: Int, _ c: CGContext) {150 _ = plate(c)151 let center = CGPoint(x: 512, y: 512)152 switch n {153 case 1: // ORIX O crossed by a system pulse154 let ring = CGMutablePath()155 ring.addArc(center: center, radius: 236, startAngle: 0.2, endAngle: .pi - 0.2, clockwise: false)156 ring.move(to: CGPoint(x: center.x + 236 * cos(.pi + 0.2), y: center.y + 236 * sin(.pi + 0.2)))157 ring.addArc(center: center, radius: 236, startAngle: .pi + 0.2, endAngle: 2 * .pi - 0.2, clockwise: false)158 strokeGradient(c, ring, width: 62)159 strokeGradient(c, pulse(from: 170, to: 854, y: 512, amplitude: 150), width: 44, colors: [0xFFFFFF, 0xDFF7FF])160 case 2: // Geometric performance waveform161 let heights: [CGFloat] = [130, 250, 420, 300, 520, 360, 210, 120]162 for (i, h) in heights.enumerated() {163 let x = 228 + CGFloat(i) * 76164 let bar = CGPath(roundedRect: CGRect(x: x, y: 512 - h / 2, width: 44, height: h), cornerWidth: 22, cornerHeight: 22, transform: nil)165 c.saveGState()166 c.addPath(bar)167 c.clip()168 c.drawLinearGradient(gradient([rgb(cyan), rgb(indigo)]), start: CGPoint(x: 228, y: 780), end: CGPoint(x: 800, y: 240), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation])169 c.restoreGState()170 }171 case 3: // Apple-Silicon-inspired chip holding a pulse172 let chip = CGRect(x: 312, y: 312, width: 400, height: 400)173 for i in 0..<4 {174 let o = 362 + CGFloat(i) * 100175 for pin in [CGRect(x: o - 14, y: 236, width: 28, height: 76), CGRect(x: o - 14, y: 712, width: 28, height: 76),176 CGRect(x: 236, y: o - 14, width: 76, height: 28), CGRect(x: 712, y: o - 14, width: 76, height: 28)] {177 c.addPath(CGPath(roundedRect: pin, cornerWidth: 14, cornerHeight: 14, transform: nil))178 }179 }180 c.setFillColor(rgb(indigo, 0.9))181 c.fillPath()182 strokeGradient(c, CGPath(roundedRect: chip, cornerWidth: 84, cornerHeight: 84, transform: nil), width: 40)183 strokeGradient(c, pulse(from: 356, to: 668, y: 512, amplitude: 96), width: 32, colors: [0xFFFFFF, 0xDFF7FF])184 case 4: // Precision telemetry ring: three gauges at different readings185 for (i, (radius, sweep)) in [(268.0, 0.82), (196.0, 0.58), (124.0, 0.36)].enumerated() {186 let track = CGMutablePath()187 track.addArc(center: center, radius: radius, startAngle: 0, endAngle: 2 * .pi, clockwise: false)188 c.addPath(track)189 c.setStrokeColor(rgb(0xFFFFFF, 0.08))190 c.setLineWidth(46)191 c.strokePath()192 let arc = CGMutablePath()193 arc.addArc(center: center, radius: radius, startAngle: .pi / 2, endAngle: .pi / 2 - 2 * .pi * sweep, clockwise: true)194 strokeGradient(c, arc, width: 46, colors: [[cyan, indigo], [indigo, violet], [0xFFFFFF, cyan]][i])195 }196 c.setFillColor(rgb(0xFFFFFF))197 c.fillEllipse(in: CGRect(x: 484, y: 484, width: 56, height: 56))198 default: // Abstract system activity: two overlapping live traces199 func trace(_ points: [(CGFloat, CGFloat)]) -> CGPath {200 let p = CGMutablePath()201 p.move(to: CGPoint(x: points[0].0, y: points[0].1))202 for i in 1..<points.count {203 let a = points[i - 1], b = points[i], mid = (a.0 + b.0) / 2204 p.addCurve(to: CGPoint(x: b.0, y: b.1), control1: CGPoint(x: mid, y: a.1), control2: CGPoint(x: mid, y: b.1))205 }206 return p207 }208 let upper: [(CGFloat, CGFloat)] = [(190, 420), (310, 560), (430, 470), (560, 700), (690, 540), (834, 640)]209 let lower: [(CGFloat, CGFloat)] = [(190, 330), (330, 400), (470, 340), (600, 480), (720, 380), (834, 430)]210 let area = CGMutablePath()211 area.addPath(trace(upper))212 area.addLine(to: CGPoint(x: 834, y: 250))213 area.addLine(to: CGPoint(x: 190, y: 250))214 area.closeSubpath()215 c.saveGState()216 c.addPath(area)217 c.clip()218 c.drawLinearGradient(gradient([rgb(cyan, 0.42), rgb(cyan, 0)]), start: CGPoint(x: 512, y: 700), end: CGPoint(x: 512, y: 250), options: [])219 c.restoreGState()220 strokeGradient(c, trace(upper), width: 44)221 strokeGradient(c, trace(lower), width: 30, colors: [violet, indigo])222 }223}224225func render(_ n: Int, size: Int) -> CGImage {226 let c = CGContext(data: nil, width: size, height: size, bitsPerComponent: 8, bytesPerRow: 0, space: space, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)!227 c.interpolationQuality = .high228 c.scaleBy(x: CGFloat(size) / 1024, y: CGFloat(size) / 1024)229 concept(n, c)230 return c.makeImage()!231}232233func write(_ image: CGImage, _ path: String) {234 try! NSBitmapImageRep(cgImage: image).representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: path))235}236237let args = CommandLine.arguments238guard args.count >= 3 else { print("usage: make-icon concepts <dir> | export <n> <dir>"); exit(2) }239if args[1] == "concepts" {240 let dir = args[2]241 try? FileManager.default.createDirectory(atPath: dir, withIntermediateDirectories: true)242 let sheet = CGContext(data: nil, width: 5 * 300 + 40, height: 520, bitsPerComponent: 8, bytesPerRow: 0, space: space, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)!243 sheet.setFillColor(rgb(0xE9EBF2))244 sheet.fill(CGRect(x: 0, y: 0, width: 1540, height: 260))245 sheet.setFillColor(rgb(0x1B1E2B))246 sheet.fill(CGRect(x: 0, y: 260, width: 1540, height: 260))247 for n in 1...5 {248 write(render(n, size: 1024), "\(dir)/concept-\(n).png")249 let x = 20 + (n - 1) * 300250 sheet.draw(render(n, size: 512), in: CGRect(x: x, y: 290, width: 220, height: 220))251 var sx = CGFloat(x)252 for s in [128, 64, 32, 16] {253 sheet.draw(render(n, size: s * 2), in: CGRect(x: sx, y: 110 - CGFloat(s) / 2 + 20, width: CGFloat(s), height: CGFloat(s)))254 sx += CGFloat(s) + 12255 }256 }257 write(sheet.makeImage()!, "\(dir)/concepts-sheet.png")258} else if args[1] == "export", args.count >= 4, let n = Int(args[2]) {259 let dir = args[3]260 try? FileManager.default.createDirectory(atPath: dir, withIntermediateDirectories: true)261 for size in [16, 32, 64, 128, 256, 512, 1024] { write(render(n, size: size), "\(dir)/icon_\(size).png") }262}263