// The invented pictures a face capture draws its records with: the covers,// posters, stills and sleeves cut from the Codex round 2 references into// `scripts/faces-walk/art/<name>.png`. With `FACES_ART=<that folder>`// (passed as `TEST_RUNNER_FACES_ART`; the simulator reads the Mac's paths) a// capture names its record's picture by the design's name and hands the// faces the file through `facePictures`, as the core would hand the bytes.// Never in the app's bundle: without the variable a capture draws its// records with no picture.#if canImport(UIKit)importCottonValuesimportSwiftUIimport UIKit@testable importCottonUIenumFacesArt {/// The folder the pictures are in, when the run names one.staticvar folder: URL? {guardlet path = ProcessInfo.processInfo.environment["FACES_ART"], !path.isEmpty else { returnnil }return URL(fileURLWithPath: path, isDirectory: true) }/// The key a record keeps for the design `name`'s picture, when it is there.staticfunc key(_ name: String) -> String? { image(name) == nil ? nil : name }/// `fields` with the design `name`'s picture as their `photo`, when it is there.staticfunc with(_ fields: [String: RecordValue], _ name: String) -> [String: RecordValue] {guardlet key = key(name) else { return fields }return fields.merging(["photo": .text(key)]) { _, picture in picture } }/// The picture under `key`, for `facePictures`.staticfunc picture(_ key: String) -> Image? { image(key).map { Image(uiImage: $0) } }staticfunc image(_ name: String) -> UIImage? {guardlet file = folder?.appendingPathComponent("\(name).png") else { returnnil }return UIImage(contentsOfFile: file.path) }}#endif