App Icon jetzt mit dabei
This commit is contained in:
1 parent
c24bc91768
commit
87ec0ab97c
6 files changed
+619
-1
No files matched your search
@@ -32,6 +32,9 @@ playground.xcworkspace
|
||||
|
||||
.build/
|
||||
|
||||
# Generated app bundle (Scripts/build-app.sh)
|
||||
build/
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
|
||||
+2
-1
@@ -175,7 +175,8 @@ sie bei der nächsten Automatik erhalten bleiben.
|
||||
## 7. Oberfläche und Interaktion
|
||||
|
||||
- **Ruhige Papieroptik** mit warmen Hintergründen, Akzentgrün, Gold und
|
||||
Burgunder; Serif-Überschriften, klare Piktogramme.
|
||||
Burgunder; Serif-Überschriften, klare Piktogramme. Das App-Icon greift die
|
||||
Gestaltung auf: eine Kirchen-Silhouette hinter einer Kalenderkarte.
|
||||
- **Kalender als Tabelle:** eine Zeile pro Tag, feste Spalten für Datum,
|
||||
Liturgie/Lesungen und die vier Kirchen. Sonntage, Hochfeste und gebotene
|
||||
Feiertage sind farblich hinterlegt; liturgische Farbbalken markieren den Tag.
|
||||
|
||||
@@ -1,2 +1,114 @@
|
||||
# LektorenPlan
|
||||
|
||||
macOS-SwiftUI-Prototyp für die Planung von Lektorinnen, Lektoren und
|
||||
Kommunionhelferinnen/-helfern in der Pfarreiengemeinschaft Bad Godesberg
|
||||
(St. Andreas, St. Evergislus, Herz Jesu, St. Hildegard).
|
||||
|
||||
Das ausführliche Grobkonzept liegt in [CONCEPT.md](CONCEPT.md).
|
||||
|
||||
## Voraussetzungen
|
||||
|
||||
- macOS 14 oder neuer
|
||||
- Xcode 15 oder neuer bzw. Swift 5.9+
|
||||
- Keine externen Abhängigkeiten
|
||||
|
||||
## Bauen und starten
|
||||
|
||||
```bash
|
||||
# Debug-Build und Tests
|
||||
swift build
|
||||
swift test
|
||||
|
||||
# App-Bundle erzeugen und öffnen
|
||||
./Scripts/build-app.sh debug
|
||||
open build/LektorenPlan.app
|
||||
```
|
||||
|
||||
Alternativ `Package.swift` in Xcode öffnen und das Schema `LektorenPlan`
|
||||
starten.
|
||||
|
||||
Die App legt ihre Datenbank unter
|
||||
`~/Library/Application Support/LektorenPlan/lektorenplan.sqlite` an und befüllt
|
||||
sie beim ersten Start mit Demo-Daten. Über **Einstellungen → Demo-Daten
|
||||
zurücksetzen** lässt sich der Ausgangszustand wiederherstellen.
|
||||
|
||||
## Funktionsüberblick
|
||||
|
||||
- **Kalender & Planung:** Tageszeilen mit Liturgie, Lesungen und Gottesdiensten
|
||||
der vier Kirchen; Sonntage, Hochfeste und gebotene Feiertage hervorgehoben.
|
||||
- **Zeitstrahl:** frei wählbarer Zeitraum mit Griffen und Marken für Quartale,
|
||||
Osterzeit, Weihnachtszeit und Kirchenjahr.
|
||||
- **Automatische Planung:** harte Ausschlüsse (Rolle, Abwesenheit, Monatslimit,
|
||||
Doppelbelegung, Einsatztag) und weiche Präferenzen (Kirche, Gottesdienst,
|
||||
Wochentag, Fairness).
|
||||
- **Manuelle Nachsteuerung:** Kandidatenvorschläge mit Warnhinweisen,
|
||||
Einsätze sperren oder entfernen.
|
||||
- **Gottesdienstordnung:** wiederkehrende Vorlagen, Ausnahmen und
|
||||
Sondergottesdienste.
|
||||
- **Team:** Personen, Rollen, Präferenzen, Abwesenheiten, Monatslimits.
|
||||
- **Statistik:** Besetzungsquote, Fairness, Monatsverlauf, Kirchenverteilung,
|
||||
Präferenztreffer, Einsatzübersicht (Swift Charts).
|
||||
- **Austausch:** JSON-Export und -Import für Planungsabschnitte oder Ressourcen
|
||||
mit Vorschau vor dem Zusammenführen.
|
||||
- **PDF & Druck:** A4 quer mit automatischer Pagination, PDFKit-Vorschau,
|
||||
Sichern und direkter Druck.
|
||||
|
||||
## Liturgische Daten
|
||||
|
||||
Die App nutzt den liturgischen Kalender für das Erzbistum Köln über
|
||||
[www.eucharistiefeier.de](https://www.eucharistiefeier.de). Für 2025–2028 ist
|
||||
ein Offline-Snapshot enthalten; der aktuelle Jahrgang kann in den Einstellungen
|
||||
oder über die Kalender-Schaltfläche online aktualisiert werden.
|
||||
|
||||
> Daten von www.eucharistiefeier.de – fair use, ausschließlich zur Anzeige.
|
||||
> Die Daten bleiben Eigentum der Quelle.
|
||||
|
||||
## Projektstruktur
|
||||
|
||||
```
|
||||
Sources/
|
||||
├── LektorenPlanCore/ Modelle, SQLite, Liturgie, Planer, Statistik
|
||||
├── LektorenPlan/ SwiftUI-App, Views, Sheets, PDF-Renderer
|
||||
Tests/LektorenPlanCoreTests/
|
||||
Resources/AppIcon.icns App-Icon
|
||||
Scripts/build-app.sh erzeugt build/LektorenPlan.app
|
||||
Scripts/make-icon.swift erzeugt Resources/AppIcon.icns
|
||||
CONCEPT.md Grobkonzept
|
||||
```
|
||||
|
||||
## App-Icon
|
||||
|
||||
Das Icon zeigt eine Kirche als Linienzeichnung im Hintergrund und eine
|
||||
stilisierte Kalenderkarte im Vordergrund. Es wird per Skript als
|
||||
ICNS-Datei erzeugt und beim Bauen ins App-Bundle kopiert:
|
||||
|
||||
```bash
|
||||
swift Scripts/make-icon.swift
|
||||
./Scripts/build-app.sh debug
|
||||
```
|
||||
|
||||
Die Vorschau in voller Auflösung landet unter `build/AppIcon-1024.png`.
|
||||
|
||||
## Entwicklungshelfer
|
||||
|
||||
Für visuelle Prüfungen ohne Bildschirmaufnahme-Berechtigung kann die App eine
|
||||
Ansicht als PNG rendern und/oder den Plan als PDF schreiben:
|
||||
|
||||
```bash
|
||||
BIN=$(swift build --show-bin-path)
|
||||
LP_SNAPSHOT=/tmp/plan.png "$BIN/LektorenPlan"
|
||||
LP_SNAPSHOT=/tmp/statistik.png LP_SNAPSHOT_VIEW=statistics \
|
||||
LP_SNAPSHOT_HEIGHT=2000 "$BIN/LektorenPlan"
|
||||
LP_PDF=/tmp/plan.pdf "$BIN/LektorenPlan"
|
||||
```
|
||||
|
||||
`LP_SNAPSHOT_VIEW` akzeptiert `planning`, `root`, `team`, `order`,
|
||||
`statistics`, `exchange` und `settings`. Der Auto-Sync ist bei
|
||||
Snapshot-Läufen deaktiviert.
|
||||
|
||||
## Status
|
||||
|
||||
Prototyp 0.1. Die Demo-Personen und Kontaktdaten sind fiktiv. Produktive
|
||||
Aspekte wie Benutzerkonten, Benachrichtigungen, Signierung und ein
|
||||
Mehrbenutzerbetrieb sind noch nicht umgesetzt; siehe Abschnitt „Grenzen“ in
|
||||
[CONCEPT.md](CONCEPT.md).
|
||||
Binary file not shown.
@@ -19,6 +19,11 @@ mkdir -p "$MACOS" "$RESOURCES"
|
||||
|
||||
cp "$BIN_DIR/LektorenPlan" "$MACOS/LektorenPlan"
|
||||
|
||||
# App icon
|
||||
if [ -f "$ROOT/Resources/AppIcon.icns" ]; then
|
||||
cp "$ROOT/Resources/AppIcon.icns" "$RESOURCES/AppIcon.icns"
|
||||
fi
|
||||
|
||||
# Copy SwiftPM resource bundles so Bundle.module keeps working inside the app.
|
||||
for bundle in "$BIN_DIR"/*.bundle; do
|
||||
[ -e "$bundle" ] || continue
|
||||
@@ -36,6 +41,8 @@ cat > "$CONTENTS/Info.plist" <<'PLIST'
|
||||
<string>LektorenPlan</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>de.badgodesberg.lektorenplan</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
Executable
+495
@@ -0,0 +1,495 @@
|
||||
#!/usr/bin/env swift
|
||||
//
|
||||
// Erzeugt das App-Icon für LektorenPlan:
|
||||
// eine Kirche als Linienzeichnung im Hintergrund, davor eine stilisierte
|
||||
// Kalenderkarte im Papier-Look der App.
|
||||
//
|
||||
// Aufruf: swift Scripts/make-icon.swift
|
||||
// Ergebnis: Resources/AppIcon.icns (und build/AppIcon-1024.png als Vorschau)
|
||||
//
|
||||
|
||||
import AppKit
|
||||
import Foundation
|
||||
|
||||
private enum Icon {
|
||||
|
||||
// MARK: - Palette
|
||||
|
||||
static func color(_ hex: UInt32, alpha: CGFloat = 1) -> NSColor {
|
||||
NSColor(
|
||||
srgbRed: CGFloat((hex >> 16) & 0xFF) / 255,
|
||||
green: CGFloat((hex >> 8) & 0xFF) / 255,
|
||||
blue: CGFloat(hex & 0xFF) / 255,
|
||||
alpha: alpha
|
||||
)
|
||||
}
|
||||
|
||||
static let paperTop = color(0xFCF6E8)
|
||||
static let paperBottom = color(0xEADDC3)
|
||||
static let accent = color(0x2E5B57)
|
||||
static let accentLight = color(0x3A716A)
|
||||
static let accentDeep = color(0x22463F)
|
||||
static let gold = color(0xB7863B)
|
||||
static let goldLight = color(0xD9B36A)
|
||||
static let burgundy = color(0x7E3D4A)
|
||||
static let cardTop = color(0xFFFEF9)
|
||||
static let cardBottom = color(0xFFF7E7)
|
||||
static let cellFill = color(0xF3EAD9)
|
||||
static let cellStroke = color(0xE0D2B8)
|
||||
static let cardStroke = color(0xE4D6BC)
|
||||
|
||||
// MARK: - Geometry
|
||||
|
||||
static let canvas: CGFloat = 1024
|
||||
static let bodyRect = NSRect(x: 100, y: 100, width: 824, height: 824)
|
||||
static let bodyRadius: CGFloat = 188
|
||||
static let cardRect = NSRect(x: 232, y: 560, width: 560, height: 336)
|
||||
static let cardRadius: CGFloat = 54
|
||||
static let bandHeight: CGFloat = 88
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
static func path(_ rect: NSRect, radius: CGFloat) -> NSBezierPath {
|
||||
NSBezierPath(roundedRect: rect, xRadius: radius, yRadius: radius)
|
||||
}
|
||||
|
||||
static func stroke(_ path: NSBezierPath, _ color: NSColor, width: CGFloat) {
|
||||
color.setStroke()
|
||||
path.lineWidth = width
|
||||
path.lineJoinStyle = .round
|
||||
path.lineCapStyle = .round
|
||||
path.stroke()
|
||||
}
|
||||
|
||||
static func fill(_ path: NSBezierPath, _ color: NSColor) {
|
||||
color.setFill()
|
||||
path.fill()
|
||||
}
|
||||
|
||||
static func fillGradient(
|
||||
_ path: NSBezierPath,
|
||||
top: NSColor,
|
||||
bottom: NSColor,
|
||||
topY: CGFloat,
|
||||
bottomY: CGFloat
|
||||
) {
|
||||
guard let gradient = NSGradient(colors: [top, bottom]) else { return }
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
path.addClip()
|
||||
gradient.draw(
|
||||
from: NSPoint(x: path.bounds.midX, y: topY),
|
||||
to: NSPoint(x: path.bounds.midX, y: bottomY),
|
||||
options: []
|
||||
)
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
}
|
||||
|
||||
static func line(_ points: [NSPoint], _ color: NSColor, width: CGFloat) {
|
||||
guard let first = points.first else { return }
|
||||
let p = NSBezierPath()
|
||||
p.move(to: first)
|
||||
for point in points.dropFirst() { p.line(to: point) }
|
||||
stroke(p, color, width: width)
|
||||
}
|
||||
|
||||
static func circle(center: NSPoint, radius: CGFloat) -> NSBezierPath {
|
||||
NSBezierPath(ovalIn: NSRect(
|
||||
x: center.x - radius,
|
||||
y: center.y - radius,
|
||||
width: radius * 2,
|
||||
height: radius * 2
|
||||
))
|
||||
}
|
||||
|
||||
// MARK: - Drawing
|
||||
|
||||
static func draw() {
|
||||
drawBody()
|
||||
drawChurch()
|
||||
drawCard()
|
||||
drawRings()
|
||||
drawGrid()
|
||||
drawDots()
|
||||
}
|
||||
|
||||
static func drawBody() {
|
||||
let body = path(bodyRect, radius: bodyRadius)
|
||||
|
||||
// Soft drop shadow.
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
let shadow = NSShadow()
|
||||
shadow.shadowColor = NSColor.black.withAlphaComponent(0.22)
|
||||
shadow.shadowBlurRadius = 38
|
||||
shadow.shadowOffset = NSSize(width: 0, height: 18)
|
||||
shadow.set()
|
||||
fill(body, paperBottom)
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
|
||||
fillGradient(body, top: paperTop, bottom: paperBottom, topY: bodyRect.minY, bottomY: bodyRect.maxY)
|
||||
|
||||
// Warm light behind the church.
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
body.addClip()
|
||||
let glowRect = NSRect(x: 232, y: 170, width: 560, height: 560)
|
||||
if let glow = NSGradient(colors: [
|
||||
gold.withAlphaComponent(0.20),
|
||||
gold.withAlphaComponent(0.0)
|
||||
]) {
|
||||
glow.draw(in: NSBezierPath(ovalIn: glowRect), relativeCenterPosition: .zero)
|
||||
}
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
|
||||
// Inner rim highlight.
|
||||
let inset = bodyRect.insetBy(dx: 3, dy: 3)
|
||||
let rim = path(inset, radius: bodyRadius - 3)
|
||||
stroke(rim, NSColor.white.withAlphaComponent(0.38), width: 2.5)
|
||||
}
|
||||
|
||||
static func drawChurch() {
|
||||
let strokeColor = accent.withAlphaComponent(0.55)
|
||||
let fillColor = accent.withAlphaComponent(0.065)
|
||||
let lineWidth: CGFloat = 11
|
||||
|
||||
// Nave
|
||||
let nave = NSBezierPath()
|
||||
nave.move(to: NSPoint(x: 348, y: 566))
|
||||
nave.line(to: NSPoint(x: 600, y: 566))
|
||||
nave.line(to: NSPoint(x: 600, y: 840))
|
||||
nave.line(to: NSPoint(x: 348, y: 840))
|
||||
nave.close()
|
||||
fill(nave, fillColor)
|
||||
stroke(nave, strokeColor, width: lineWidth)
|
||||
|
||||
// Gable roof
|
||||
let roof = NSBezierPath()
|
||||
roof.move(to: NSPoint(x: 312, y: 574))
|
||||
roof.line(to: NSPoint(x: 474, y: 354))
|
||||
roof.line(to: NSPoint(x: 636, y: 574))
|
||||
roof.close()
|
||||
fill(roof, fillColor)
|
||||
stroke(roof, strokeColor, width: lineWidth)
|
||||
|
||||
// Tower
|
||||
let tower = NSBezierPath()
|
||||
tower.move(to: NSPoint(x: 596, y: 500))
|
||||
tower.line(to: NSPoint(x: 716, y: 500))
|
||||
tower.line(to: NSPoint(x: 716, y: 840))
|
||||
tower.line(to: NSPoint(x: 596, y: 840))
|
||||
tower.close()
|
||||
fill(tower, fillColor)
|
||||
stroke(tower, strokeColor, width: lineWidth)
|
||||
|
||||
// Spire
|
||||
let spire = NSBezierPath()
|
||||
spire.move(to: NSPoint(x: 584, y: 506))
|
||||
spire.line(to: NSPoint(x: 656, y: 296))
|
||||
spire.line(to: NSPoint(x: 728, y: 506))
|
||||
spire.close()
|
||||
fill(spire, fillColor)
|
||||
stroke(spire, strokeColor, width: lineWidth)
|
||||
|
||||
// Cross on the tower
|
||||
line([NSPoint(x: 656, y: 296), NSPoint(x: 656, y: 230)], gold, width: 13)
|
||||
line([NSPoint(x: 620, y: 263), NSPoint(x: 692, y: 263)], gold, width: 13)
|
||||
|
||||
// Small cross on the nave gable
|
||||
line([NSPoint(x: 474, y: 354), NSPoint(x: 474, y: 322)], gold, width: 8)
|
||||
line([NSPoint(x: 457, y: 338), NSPoint(x: 491, y: 338)], gold, width: 8)
|
||||
|
||||
// Rose window
|
||||
let roseCenter = NSPoint(x: 474, y: 452)
|
||||
let rose = circle(center: roseCenter, radius: 42)
|
||||
stroke(rose, accent.withAlphaComponent(0.52), width: 10)
|
||||
for index in 0..<8 {
|
||||
let angle = CGFloat(index) * .pi / 4
|
||||
let from = NSPoint(
|
||||
x: roseCenter.x + cos(angle) * 11,
|
||||
y: roseCenter.y + sin(angle) * 11
|
||||
)
|
||||
let to = NSPoint(
|
||||
x: roseCenter.x + cos(angle) * 35,
|
||||
y: roseCenter.y + sin(angle) * 35
|
||||
)
|
||||
line([from, to], accent.withAlphaComponent(0.30), width: 5)
|
||||
}
|
||||
fill(circle(center: roseCenter, radius: 8), accent.withAlphaComponent(0.18))
|
||||
|
||||
// Belfry window
|
||||
let belfry = path(NSRect(x: 634, y: 516, width: 44, height: 64), radius: 22)
|
||||
stroke(belfry, accent.withAlphaComponent(0.46), width: 8)
|
||||
line([NSPoint(x: 656, y: 528), NSPoint(x: 656, y: 566)], accent.withAlphaComponent(0.30), width: 4)
|
||||
}
|
||||
|
||||
static func drawRings() {
|
||||
for centerX in [CGFloat(400), CGFloat(624)] {
|
||||
let ringRect = NSRect(x: centerX - 15, y: 506, width: 30, height: 84)
|
||||
let ring = path(ringRect, radius: 15)
|
||||
|
||||
// Slight shadow so the rings sit on top of the band.
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
let shadow = NSShadow()
|
||||
shadow.shadowColor = NSColor.black.withAlphaComponent(0.20)
|
||||
shadow.shadowBlurRadius = 8
|
||||
shadow.shadowOffset = NSSize(width: 0, height: 4)
|
||||
shadow.set()
|
||||
fill(ring, gold)
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
|
||||
fillGradient(ring, top: goldLight, bottom: gold, topY: ringRect.minY, bottomY: ringRect.maxY)
|
||||
stroke(ring, gold.withAlphaComponent(0.65), width: 2.5)
|
||||
|
||||
// Soft highlight on the left flank.
|
||||
let highlight = path(
|
||||
NSRect(x: ringRect.minX + 4, y: ringRect.minY + 10, width: 5, height: ringRect.height - 20),
|
||||
radius: 2.5
|
||||
)
|
||||
fill(highlight, NSColor.white.withAlphaComponent(0.32))
|
||||
}
|
||||
}
|
||||
|
||||
static func drawCard() {
|
||||
let card = path(cardRect, radius: cardRadius)
|
||||
|
||||
// Shadow
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
let shadow = NSShadow()
|
||||
shadow.shadowColor = NSColor.black.withAlphaComponent(0.18)
|
||||
shadow.shadowBlurRadius = 30
|
||||
shadow.shadowOffset = NSSize(width: 0, height: 16)
|
||||
shadow.set()
|
||||
fill(card, cardBottom)
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
|
||||
fillGradient(card, top: cardTop, bottom: cardBottom, topY: cardRect.minY, bottomY: cardRect.maxY)
|
||||
|
||||
// Accent band
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
card.addClip()
|
||||
let band = NSRect(x: cardRect.minX, y: cardRect.minY, width: cardRect.width, height: bandHeight)
|
||||
let bandPath = NSBezierPath(rect: band)
|
||||
fillGradient(
|
||||
bandPath,
|
||||
top: accentLight,
|
||||
bottom: accentDeep,
|
||||
topY: band.minY,
|
||||
bottomY: band.maxY
|
||||
)
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
|
||||
// Thin gold seam under the band
|
||||
line(
|
||||
[NSPoint(x: cardRect.minX + 2, y: cardRect.minY + bandHeight),
|
||||
NSPoint(x: cardRect.maxX - 2, y: cardRect.minY + bandHeight)],
|
||||
gold.withAlphaComponent(0.9),
|
||||
width: 3
|
||||
)
|
||||
|
||||
// Small gold cross in the band
|
||||
let bandCenterY = cardRect.minY + bandHeight / 2
|
||||
line([NSPoint(x: 512, y: bandCenterY - 22), NSPoint(x: 512, y: bandCenterY + 20)], gold, width: 6)
|
||||
line([NSPoint(x: 491, y: bandCenterY - 4), NSPoint(x: 533, y: bandCenterY - 4)], gold, width: 6)
|
||||
|
||||
// Card outline
|
||||
stroke(card, cardStroke, width: 2.5)
|
||||
}
|
||||
|
||||
static func drawGrid() {
|
||||
let columns = 5
|
||||
let rows = 3
|
||||
let cellWidth: CGFloat = 79
|
||||
let cellHeight: CGFloat = 48
|
||||
let gapX: CGFloat = 14
|
||||
let gapY: CGFloat = 12
|
||||
|
||||
let totalWidth = CGFloat(columns) * cellWidth + CGFloat(columns - 1) * gapX
|
||||
let originX = cardRect.midX - totalWidth / 2
|
||||
let originY = cardRect.minY + bandHeight + 30
|
||||
|
||||
for row in 0..<rows {
|
||||
for column in 0..<columns {
|
||||
let rect = NSRect(
|
||||
x: originX + CGFloat(column) * (cellWidth + gapX),
|
||||
y: originY + CGFloat(row) * (cellHeight + gapY),
|
||||
width: cellWidth,
|
||||
height: cellHeight
|
||||
)
|
||||
let cell = path(rect, radius: 12)
|
||||
|
||||
switch (row, column) {
|
||||
case (1, 1):
|
||||
fillGradient(
|
||||
cell,
|
||||
top: accentLight,
|
||||
bottom: accentDeep,
|
||||
topY: rect.minY,
|
||||
bottomY: rect.maxY
|
||||
)
|
||||
let center = NSPoint(x: rect.midX, y: rect.midY)
|
||||
line([NSPoint(x: center.x, y: center.y - 13), NSPoint(x: center.x, y: center.y + 12)],
|
||||
NSColor.white.withAlphaComponent(0.95), width: 4.5)
|
||||
line([NSPoint(x: center.x - 9, y: center.y - 3), NSPoint(x: center.x + 9, y: center.y - 3)],
|
||||
NSColor.white.withAlphaComponent(0.95), width: 4.5)
|
||||
case (2, 3):
|
||||
fillGradient(
|
||||
cell,
|
||||
top: goldLight,
|
||||
bottom: gold,
|
||||
topY: rect.minY,
|
||||
bottomY: rect.maxY
|
||||
)
|
||||
fill(circle(center: NSPoint(x: rect.midX, y: rect.midY), radius: 7),
|
||||
NSColor.white.withAlphaComponent(0.95))
|
||||
default:
|
||||
fill(cell, cellFill)
|
||||
stroke(cell, cellStroke, width: 1.6)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func drawDots() {
|
||||
// One dot per church, using the app's church colours.
|
||||
let colors = [color(0x9B5B44), color(0x4E6E5D), color(0x7A5A78), color(0xB0833C)]
|
||||
let radius: CGFloat = 6.5
|
||||
let spacing: CGFloat = 24
|
||||
let totalWidth = CGFloat(colors.count - 1) * spacing
|
||||
let startX = 512 - totalWidth / 2
|
||||
let y = cardRect.maxY - 30
|
||||
|
||||
for (index, color) in colors.enumerated() {
|
||||
fill(circle(center: NSPoint(x: startX + CGFloat(index) * spacing, y: y), radius: radius), color)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Rendering
|
||||
|
||||
static func renderMaster() -> NSBitmapImageRep {
|
||||
guard let rep = NSBitmapImageRep(
|
||||
bitmapDataPlanes: nil,
|
||||
pixelsWide: Int(canvas),
|
||||
pixelsHigh: Int(canvas),
|
||||
bitsPerSample: 8,
|
||||
samplesPerPixel: 4,
|
||||
hasAlpha: true,
|
||||
isPlanar: false,
|
||||
colorSpaceName: .deviceRGB,
|
||||
bytesPerRow: 0,
|
||||
bitsPerPixel: 0
|
||||
) else { fatalError("Bitmap konnte nicht erzeugt werden") }
|
||||
rep.size = NSSize(width: canvas, height: canvas)
|
||||
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
guard let context = NSGraphicsContext(bitmapImageRep: rep) else {
|
||||
fatalError("Grafikkontext konnte nicht erzeugt werden")
|
||||
}
|
||||
NSGraphicsContext.current = context
|
||||
context.imageInterpolation = .high
|
||||
context.shouldAntialias = true
|
||||
|
||||
// Flip to a top-left origin so the drawing code reads top-to-bottom.
|
||||
let transform = NSAffineTransform()
|
||||
transform.translateX(by: 0, yBy: canvas)
|
||||
transform.scaleX(by: 1, yBy: -1)
|
||||
transform.concat()
|
||||
|
||||
draw()
|
||||
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
return rep
|
||||
}
|
||||
|
||||
static func pngData(from image: NSImage, size: Int) -> Data? {
|
||||
guard let rep = NSBitmapImageRep(
|
||||
bitmapDataPlanes: nil,
|
||||
pixelsWide: size,
|
||||
pixelsHigh: size,
|
||||
bitsPerSample: 8,
|
||||
samplesPerPixel: 4,
|
||||
hasAlpha: true,
|
||||
isPlanar: false,
|
||||
colorSpaceName: .deviceRGB,
|
||||
bytesPerRow: 0,
|
||||
bitsPerPixel: 0
|
||||
) else { return nil }
|
||||
rep.size = NSSize(width: size, height: size)
|
||||
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
guard let context = NSGraphicsContext(bitmapImageRep: rep) else { return nil }
|
||||
NSGraphicsContext.current = context
|
||||
context.imageInterpolation = .high
|
||||
context.shouldAntialias = true
|
||||
NSColor.clear.setFill()
|
||||
NSRect(x: 0, y: 0, width: size, height: size).fill()
|
||||
image.draw(
|
||||
in: NSRect(x: 0, y: 0, width: size, height: size),
|
||||
from: NSRect(x: 0, y: 0, width: canvas, height: canvas),
|
||||
operation: .sourceOver,
|
||||
fraction: 1
|
||||
)
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
return rep.representation(using: .png, properties: [:])
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Main
|
||||
|
||||
let root = URL(fileURLWithPath: #filePath)
|
||||
.deletingLastPathComponent()
|
||||
.deletingLastPathComponent()
|
||||
let resources = root.appendingPathComponent("Resources", isDirectory: true)
|
||||
let build = root.appendingPathComponent("build", isDirectory: true)
|
||||
let fileManager = FileManager.default
|
||||
|
||||
try fileManager.createDirectory(at: resources, withIntermediateDirectories: true)
|
||||
try fileManager.createDirectory(at: build, withIntermediateDirectories: true)
|
||||
|
||||
let masterRep = Icon.renderMaster()
|
||||
guard let masterPNG = masterRep.representation(using: .png, properties: [:]) else {
|
||||
fatalError("Master-PNG konnte nicht erzeugt werden")
|
||||
}
|
||||
try masterPNG.write(to: build.appendingPathComponent("AppIcon-1024.png"))
|
||||
|
||||
guard let masterImage = NSImage(data: masterPNG) else {
|
||||
fatalError("Master-Bild konnte nicht geladen werden")
|
||||
}
|
||||
|
||||
let iconset = resources.appendingPathComponent("AppIcon.iconset", isDirectory: true)
|
||||
try? fileManager.removeItem(at: iconset)
|
||||
try fileManager.createDirectory(at: iconset, withIntermediateDirectories: true)
|
||||
|
||||
let variants: [(name: String, size: Int)] = [
|
||||
("icon_16x16", 16),
|
||||
("icon_16x16@2x", 32),
|
||||
("icon_32x32", 32),
|
||||
("icon_32x32@2x", 64),
|
||||
("icon_128x128", 128),
|
||||
("icon_128x128@2x", 256),
|
||||
("icon_256x256", 256),
|
||||
("icon_256x256@2x", 512),
|
||||
("icon_512x512", 512),
|
||||
("icon_512x512@2x", 1024)
|
||||
]
|
||||
|
||||
for variant in variants {
|
||||
guard let data = Icon.pngData(from: masterImage, size: variant.size) else {
|
||||
fatalError("PNG für \(variant.name) konnte nicht erzeugt werden")
|
||||
}
|
||||
try data.write(to: iconset.appendingPathComponent("\(variant.name).png"))
|
||||
}
|
||||
|
||||
let icnsURL = resources.appendingPathComponent("AppIcon.icns")
|
||||
try? fileManager.removeItem(at: icnsURL)
|
||||
|
||||
let iconutil = Process()
|
||||
iconutil.executableURL = URL(fileURLWithPath: "/usr/bin/iconutil")
|
||||
iconutil.arguments = ["-c", "icns", iconset.path, "-o", icnsURL.path]
|
||||
try iconutil.run()
|
||||
iconutil.waitUntilExit()
|
||||
guard iconutil.terminationStatus == 0 else {
|
||||
fatalError("iconutil ist mit Status \(iconutil.terminationStatus) fehlgeschlagen")
|
||||
}
|
||||
|
||||
try? fileManager.removeItem(at: iconset)
|
||||
|
||||
print("Icon erzeugt: \(icnsURL.path)")
|
||||
print("Vorschau: \(build.appendingPathComponent("AppIcon-1024.png").path)")
|
||||
Reference in new issue
Block a user