Files
pokerfreak/mac/werkzeug/icon.swift
T
mmintel faebc1df04 mac: Swift ohne live im Dateinamen, Positions-Spec ohne live
LiveTische.swift -> Tische.swift, LiveKachel.swift -> Kachel.swift (Swift importiert keine
Dateien, also ohne Folgen); tests/live_position_spec.py -> tests/position_spec.py mit den
zwei Verweisen. Swift 132 gruen, die drei Specs gruen. Der Putz hatte in Swift #expect fuer
einen #-Kommentar gehalten - mac deshalb von vor dem Putz neu geputzt.
2026-11-01 22:33:57 +01:00

39 lines
2.0 KiB
Swift

// Zeichnet das App-Symbol (Pik auf dunklem Filz) in alle Groessen eines .iconset.
// swift werkzeug/icon.swift <ziel.iconset>
import AppKit
let ziel = URL(filePath: CommandLine.arguments[1], directoryHint: .isDirectory)
try? FileManager.default.createDirectory(at: ziel, withIntermediateDirectories: true)
func zeichnen(_ px: Int) -> Data? {
let s = CGFloat(px)
guard let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: px, pixelsHigh: px, bitsPerSample: 8,
samplesPerPixel: 4, hasAlpha: true, isPlanar: false,
colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0) else { return nil }
NSGraphicsContext.saveGraphicsState()
NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)
let rand = s * 0.1
let feld = NSRect(x: rand, y: rand, width: s - 2 * rand, height: s - 2 * rand)
let form = NSBezierPath(roundedRect: feld, xRadius: feld.width * 0.225, yRadius: feld.width * 0.225)
NSGradient(colors: [NSColor(red: 0.05, green: 0.36, blue: 0.24, alpha: 1),
NSColor(red: 0.01, green: 0.16, blue: 0.11, alpha: 1)])?.draw(in: form, angle: -90)
NSColor.white.withAlphaComponent(0.12).setStroke()
form.lineWidth = max(1, s * 0.006)
form.stroke()
let konf = NSImage.SymbolConfiguration(pointSize: s * 0.42, weight: .semibold)
.applying(.init(paletteColors: [.white]))
if let pik = NSImage(systemSymbolName: "suit.spade.fill", accessibilityDescription: nil)?.withSymbolConfiguration(konf) {
let g = pik.size
pik.draw(in: NSRect(x: (s - g.width) / 2, y: (s - g.height) / 2 + s * 0.01, width: g.width, height: g.height))
}
NSGraphicsContext.restoreGraphicsState()
return rep.representation(using: .png, properties: [:])
}
for basis in [16, 32, 128, 256, 512] {
for faktor in [1, 2] {
let name = "icon_\(basis)x\(basis)" + (faktor == 2 ? "@2x" : "") + ".png"
try zeichnen(basis * faktor)?.write(to: ziel.appending(path: name))
}
}