Breaking
Percentage *and/now support scalar overloads, so expressions like50% * 2and100% / 2change behavior from percent-to-percent math to scalar math.- Compound assignments with scalars change accordingly, for example
value *= 2now doubles the percent instead of treating2as2%. postfix %now accepts allBinaryFloatingPointtypes, which can cause ambiguity if another module defines its own postfix%forFloatorCGFloat.
Improvements
You can now use Percentage directly with common SwiftUI, UIKit, and AppKit APIs that accept a fraction Double:
Text("Hello")
.opacity(45%)
.brightness(20%)
.contrast(80%)
.saturation(50%)
.grayscale(100%)
Color.red.opacity(50%)
UIColor.red.withAlphaComponent(50%)
NSColor.red.withAlphaComponent(50%)