Repository Public
1// VQuant iOS2// File: Scripts/sheet.swift3// Description: Contact sheet of screenshots for visual review: `swift Scripts/sheet.swift out.png cellWidth a.png b.png …`4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import AppKit8let args = CommandLine.arguments9let out = args[1], cell = CGFloat(Double(args[2])!)10let images = args.dropFirst(3).compactMap { NSImage(contentsOfFile: $0) }11let heights = images.map { $0.size.height / $0.size.width * cell }12let h = heights.max() ?? 113let size = NSSize(width: (cell + 10) * CGFloat(images.count) + 10, height: h + 20)14let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: Int(size.width), pixelsHigh: Int(size.height), bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!15NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)16NSColor.darkGray.setFill(); NSRect(origin: .zero, size: size).fill()17for (i, img) in images.enumerated() { img.draw(in: NSRect(x: 10 + CGFloat(i) * (cell + 10), y: size.height - 10 - heights[i], width: cell, height: heights[i])) }18try! rep.representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: out))19