Files

44 lines
1.5 KiB
Swift

import Foundation
/// One screenshot plus everything needed to place it on a PDF page.
public struct Capture: Codable, Sendable, Identifiable, Equatable {
public let id: UUID
/// 1-based position within its session. Stable; never renumbered on delete.
public let sequence: Int
/// File name only (e.g. "001-A1B2C3D4.png"), never a path.
/// The directory is always the owning session's directory.
public let fileName: String
/// Pixel dimensions of the PNG on disk.
public let pixelWidth: Int
public let pixelHeight: Int
/// Backing scale the capture was taken at (2.0 on Retina). Needed so the PDF
/// composer lays the image out at its true point size, not its pixel size.
public let scale: CGFloat
/// When the screenshot was taken. Always stored as an absolute instant;
/// rendered in Asia/Dubai wherever a human sees it.
public let capturedAt: Date
public init(
id: UUID,
sequence: Int,
fileName: String,
pixelWidth: Int,
pixelHeight: Int,
scale: CGFloat,
capturedAt: Date
) {
self.id = id
self.sequence = sequence
self.fileName = fileName
self.pixelWidth = pixelWidth
self.pixelHeight = pixelHeight
self.scale = scale
self.capturedAt = capturedAt
}
/// True when the image is wider than it is tall. Drives page orientation.
public var isLandscape: Bool {
pixelWidth > pixelHeight
}
}