CHGenerator/WebsiteGenerator/Files/ImageOutput.swift
Christoph Hagen 80d3c08a93 Update generation
- Move to global objects for files and validation
- Only write changed files
- Check images for changes before scaling
- Simplify code
2022-08-26 17:40:51 +02:00

25 lines
498 B
Swift

import Foundation
struct ImageOutput: Hashable {
let source: String
let width: Int
let desiredHeight: Int?
var ratio: Float? {
guard let desiredHeight = desiredHeight else {
return nil
}
return Float(desiredHeight) / Float(width)
}
func hasSimilarRatio(as other: ImageOutput) -> Bool {
guard let other = other.ratio, let ratio = ratio else {
return true
}
return abs(other - ratio) < 0.1
}
}