diff --git a/Preview/PreviewApp.swift b/Preview/PreviewApp.swift index 69026b1..9ae42b1 100644 --- a/Preview/PreviewApp.swift +++ b/Preview/PreviewApp.swift @@ -16,7 +16,7 @@ import AppKit /// NecoSaverPreview --snapshot out.png --cats 5 # override the saved cat count /// NecoSaverPreview --snapshot out.png --speed 4 # override the saved speed /// NecoSaverPreview --snapshot out.png --picture pic.png # override the backdrop -/// NecoSaverPreview --snapshot out.png --grey # ... or leave the grey showing +/// NecoSaverPreview --snapshot out.png --no-picture # ... or leave the black /// NecoSaverPreview --snapshot out.png --options # render the Options sheet instead /// /// `--size` is in points; snapshots are written at 2x, as on a Retina display. @@ -123,7 +123,7 @@ enum PreviewApp { if let picture = options.picture { settings.picturePath = picture } - if options.grey { + if options.noPicture { settings.pictureEnabled = false } @@ -217,7 +217,7 @@ private struct Options { var cats: Int? var speed: Double? var picture: String? - var grey = false + var noPicture = false init(_ arguments: some Sequence) throws { var explicitSize = false @@ -228,8 +228,8 @@ private struct Options { showOptions = true case "--preview": isPreview = true - case "--grey": - grey = true + case "--no-picture": + noPicture = true case "--snapshot", "--frames", "--size", "--cats", "--speed", "--picture": let raw = try Self.value(after: argument, from: &iterator) try set(argument, to: raw, explicitSize: &explicitSize) diff --git a/README.md b/README.md index 4b108b4..663ced2 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,7 @@ random point instead of the pointer. | Cats | 1 | 1–8 | Cats on screen. Each one wanders on its own. | | Size | 64 pt | 32–192 pt | How big the cat is drawn. Walking speed and the size of the mess scale with it. | | Speed | 1.00× | 0.2–3.0 | | -| Picture | on, your wallpaper | | The picture the cats walk on, by path. Type one, or press `Choose…`. Turn it off, or empty the field, for the grey. | -| Grey level | 0% | 0–100% | The colour behind the cats when no picture is drawn, either by choice or because the path could not be read. | +| Picture | on, your wallpaper | | The picture the cats walk on, by path. Type one, or press `Choose…`. Turn it off, or empty the field, for a plain black screen. | | Paw prints | on | | Dropped while running; fade out after 12 s. | | Scratch marks | on | | Dropped while the cat works its claws; fade out after 20 s. | diff --git a/Sources/ConfigureSheetController.swift b/Sources/ConfigureSheetController.swift index bac67a1..5c53db0 100644 --- a/Sources/ConfigureSheetController.swift +++ b/Sources/ConfigureSheetController.swift @@ -86,7 +86,6 @@ final class ConfigureSheetController: NSObject { let integer: (Double) -> String = { String(Int($0.rounded())) } let multiplier: (Double) -> String = { String(format: "%.2f×", $0) } let points: (Double) -> String = { String(format: "%.0f pt", $0 * Double(Sprites.width)) } - let percent: (Double) -> String = { String(format: "%.0f%%", $0 * 100) } let settings = NecoSaverSettings.self return [ @@ -100,11 +99,6 @@ final class ConfigureSheetController: NSObject { describe: multiplier, read: { $0.speed }, write: { $0.speed = $1 }), makePictureRow(), - // Named for what it does. It is the whole backdrop only when no - // picture is drawn, so "Background" would overstate it. - makeRow(title: "Grey level:", control: makeSlider(range: settings.backgroundRange), - describe: percent, read: { $0.background }, - write: { $0.background = $1 }), makeCheckboxRow(title: "Paw prints", read: { $0.pawsEnabled }, write: { $0.pawsEnabled = $1 }), makeCheckboxRow(title: "Scratch marks", read: { $0.scratchEnabled }, diff --git a/Sources/Litter.swift b/Sources/Litter.swift index 29ebdc2..51ca5ee 100644 --- a/Sources/Litter.swift +++ b/Sources/Litter.swift @@ -32,7 +32,7 @@ final class LitterField { /// How much bigger than Neco's own cat these marks belong to (Tuning.unit), so /// the mess grows with the sprite. var unit: CGFloat = 1 - /// Mark colour, picked against the background by the engine. + /// Mark colour, picked against the backdrop by the engine. var ink: NSColor = .black private var marks: [Mark] = [] diff --git a/Sources/NecoSaverEngine.swift b/Sources/NecoSaverEngine.swift index 1995df4..545ee0f 100644 --- a/Sources/NecoSaverEngine.swift +++ b/Sources/NecoSaverEngine.swift @@ -11,7 +11,7 @@ final class NecoSaverEngine { /// The desktop picture to sit the cats on. Supplied by the host rather than /// read here: the wallpaper is per display, and only the view knows which - /// display it landed on. Left nil, the backdrop is `settings.background`. + /// display it landed on. Left nil, the backdrop is plain black. var wallpaper: Wallpaper? { didSet { configureLitter() } } @@ -91,7 +91,7 @@ final class NecoSaverEngine { if let backdrop { backdrop.draw(in: rect, context: context) } else { - context.setFillColor(NSColor(calibratedWhite: settings.background, alpha: 1).cgColor) + context.setFillColor(NSColor.black.cgColor) context.fill(rect) } @@ -112,7 +112,7 @@ final class NecoSaverEngine { Tuning(scale: settings.size, speedFactor: settings.speed) } - /// The picture to sit the cats on, if one was supplied. Nil leaves the grey: + /// The picture to sit the cats on, if one was supplied. Nil leaves the black: /// either it was asked for, or nothing could be read. private var backdrop: Wallpaper? { settings.pictureEnabled ? wallpaper : nil @@ -124,7 +124,7 @@ final class NecoSaverEngine { litter.unit = tuning.unit // Dark marks vanish on a dark backdrop and vice versa, so the ink takes the // opposite end from whatever the floor turns out to be. - let floor = backdrop.map { $0.brightness(in: bounds) } ?? CGFloat(settings.background) + let floor = backdrop.map { $0.brightness(in: bounds) } ?? 0 litter.ink = NSColor(calibratedWhite: floor < 0.5 ? 0.9 : 0.1, alpha: 1) } } diff --git a/Sources/NecoSaverSettings.swift b/Sources/NecoSaverSettings.swift index c46587c..ad1d7bd 100644 --- a/Sources/NecoSaverSettings.swift +++ b/Sources/NecoSaverSettings.swift @@ -16,15 +16,11 @@ struct NecoSaverSettings: Equatable { /// size Neco itself uses. var size: Double var speed: Double - /// Background grey level, 0 = black ... 1 = white. The cat is black ink on a - /// white body, so it reads at either end; the litter marks flip to suit. Used - /// whenever no picture is drawn, either by choice or because none could be read. - var background: Double - /// Draw `picturePath` behind the cats rather than the flat grey. + /// Draw `picturePath` behind the cats rather than the plain black. var pictureEnabled: Bool /// The picture to draw. Seeded once with the desktop's wallpaper (see /// `seedPicturePath`), an ordinary saved value from then on; empty, or naming - /// a file that cannot be read, leaves the grey showing. + /// a file that cannot be read, leaves the black showing. var picturePath: String var pawsEnabled: Bool var scratchEnabled: Bool @@ -33,7 +29,6 @@ struct NecoSaverSettings: Equatable { catCount: 1, size: 2.0, speed: 1.0, - background: 0.0, pictureEnabled: true, picturePath: "", pawsEnabled: true, @@ -43,13 +38,11 @@ struct NecoSaverSettings: Equatable { static let catCountRange = 1 ... 8 static let sizeRange = 1.0 ... 6.0 static let speedRange = 0.2 ... 3.0 - static let backgroundRange = 0.0 ... 1.0 private enum Key { static let catCount = "catCount" static let size = "size" static let speed = "speed" - static let background = "background" static let pictureEnabled = "pictureEnabled" static let picturePath = "picturePath" static let pawsEnabled = "pawsEnabled" @@ -62,7 +55,6 @@ struct NecoSaverSettings: Equatable { Key.catCount: standard.catCount, Key.size: standard.size, Key.speed: standard.speed, - Key.background: standard.background, Key.pictureEnabled: standard.pictureEnabled, Key.picturePath: standard.picturePath, Key.pawsEnabled: standard.pawsEnabled, @@ -79,7 +71,6 @@ struct NecoSaverSettings: Equatable { catCount: catCountRange.clamping(store.integer(forKey: Key.catCount)), size: sizeRange.clamping(store.double(forKey: Key.size)), speed: speedRange.clamping(store.double(forKey: Key.speed)), - background: backgroundRange.clamping(store.double(forKey: Key.background)), pictureEnabled: store.bool(forKey: Key.pictureEnabled), picturePath: store.string(forKey: Key.picturePath) ?? standard.picturePath, pawsEnabled: store.bool(forKey: Key.pawsEnabled), @@ -99,7 +90,7 @@ struct NecoSaverSettings: Equatable { /// Fills in the picture on first run, when nothing has been chosen yet: the /// desktop's own wallpaper stands in, and is written down. From then on it is /// an ordinary saved value — changing the wallpaper later leaves the backdrop - /// alone, and clearing the field leaves the grey. + /// alone, and clearing the field leaves the black. mutating func seedPicturePath(with path: String) { guard picturePath.isEmpty, !path.isEmpty, let store = Self.store else { return } picturePath = path @@ -112,7 +103,6 @@ struct NecoSaverSettings: Equatable { store.set(catCount, forKey: Key.catCount) store.set(size, forKey: Key.size) store.set(speed, forKey: Key.speed) - store.set(background, forKey: Key.background) store.set(pictureEnabled, forKey: Key.pictureEnabled) store.set(picturePath, forKey: Key.picturePath) store.set(pawsEnabled, forKey: Key.pawsEnabled) diff --git a/Sources/NecoSaverView.swift b/Sources/NecoSaverView.swift index e7bd530..ea1d8d8 100644 --- a/Sources/NecoSaverView.swift +++ b/Sources/NecoSaverView.swift @@ -76,7 +76,7 @@ final class NecoSaverView: ScreenSaverView { } /// Reads a picture only when one is going to be drawn — decoding one costs - /// several megabytes that a grey backdrop has no use for. + /// several megabytes that a black backdrop has no use for. private func loadWallpaper() { engine.wallpaper = Wallpaper.matching(engine.settings, on: window?.screen) } diff --git a/Sources/Wallpaper.swift b/Sources/Wallpaper.swift index 691f5ab..ada6709 100644 --- a/Sources/Wallpaper.swift +++ b/Sources/Wallpaper.swift @@ -7,7 +7,7 @@ import AppKit /// (plus `com.apple.security.assets.pictures.read-only`), so a picture anywhere on /// disk opens with no bookmark and no panel. Everything here degrades to `nil` /// rather than throwing — a path can name a file that has moved, or a video — and -/// the engine falls back to a plain grey. +/// the engine falls back to plain black. @MainActor struct Wallpaper { private let image: NSImage @@ -15,7 +15,7 @@ struct Wallpaper { private let allowsClipping: Bool private let fillColor: NSColor - /// The picture the settings ask for, or nil to leave the grey showing. + /// The picture the settings ask for, or nil to leave the black showing. static func matching(_ settings: NecoSaverSettings, on screen: NSScreen?) -> Wallpaper? { guard settings.pictureEnabled else { return nil } return picture(atPath: settings.picturePath, on: screen)