Files
haptika/mobile/scripts/contact-sheet.swift
2026-09-08 09:07:27 +02:00

15 lines
1.0 KiB
Swift

import AppKit
let root=CommandLine.arguments[1]
let ids=["2-2","2-30","2-268","2-334","431-2","617-952","564-904","564-853","565-958","565-1148","565-1624","565-1584","565-2383","565-3079","565-3566","565-3818","566-7582","566-7702","566-9809","580-286"]
let cellW=220,cellH=505,columns=4,rows=(ids.count+3)/4
let image=NSImage(size:NSSize(width:cellW*columns,height:cellH*rows))
image.lockFocus()
NSColor(calibratedRed:0.035,green:0.055,blue:0.085,alpha:1).setFill();NSRect(x:0,y:0,width:cellW*columns,height:cellH*rows).fill()
for (i,id) in ids.enumerated(){let x=(i%columns)*cellW+9,y=(rows-1-i/columns)*cellH+28
if let shot=NSImage(contentsOfFile:root+"/screens/"+id+".png"){shot.draw(in:NSRect(x:x,y:y,width:202,height:439))}
(id as NSString).draw(at:NSPoint(x:x,y:y-19),withAttributes:[.font:NSFont.monospacedSystemFont(ofSize:11,weight:.regular),.foregroundColor:NSColor.white])
}
image.unlockFocus()
let rep=NSBitmapImageRep(data:image.tiffRepresentation!)!
try rep.representation(using:.png,properties:[:])!.write(to:URL(fileURLWithPath:root+"/overview.png"))