https://github.com/cascable/stopkit
Stop! In the name of light! 🎶 — A simple iOS and Mac framework for working with units of light.
https://github.com/cascable/stopkit
ios ios-sdk mac objective-c photography swift
Last synced: 4 months ago
JSON representation
Stop! In the name of light! 🎶 — A simple iOS and Mac framework for working with units of light.
- Host: GitHub
- URL: https://github.com/cascable/stopkit
- Owner: Cascable
- License: mit
- Created: 2017-10-20T07:59:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-31T12:55:57.000Z (about 2 years ago)
- Last Synced: 2024-07-18T13:06:57.979Z (almost 2 years ago)
- Topics: ios, ios-sdk, mac, objective-c, photography, swift
- Language: Objective-C
- Homepage: http://developer.cascable.se/
- Size: 78.1 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/Carthage/Carthage)
# StopKit
`StopKit` is a small iOS and Mac framework for working with units of light in photography. `StopKit` is fully compatible with both Objective-C and Swift.
Here at Cascable, we use `StopKit` extensively — In our camera SDK [CascableCore](https://developer.cascable.se/), camera exposure properties such as shutter speed, aperture, exposure compensation, ISO, etc are all `StopKit` values, and our consumer app [Cascable](http://cascable.se/) uses `StopKit` to power its Shutter Robot automation tool.
## Examples
### Comparing Values
When comparing values, `StopKit` provides `compare(_:)` and `stopsDifference(from:)`. Since you can't compare indeterminate values with determinate values, these methods can fail, returning `ExposureComparisonInvalid` or `nil` respectively. You can use the `isDeterminate` property to exclude such values from calculations.
In general, a postive stops value means "more light" or "a brighter image", and a negative value means "less light" or "a darker image". However, `compare(_:)` will return a result that sorts the values into what the user would typically consider "correct" (for example, aperture values have the smallest number/largest stops value at the beginning of the list).
```swift
print(ApertureValue.f8.stopsDifference(from: ApertureValue.f4))
// -2 stops (since f8 lets less light through than f4)
print(ApertureValue.f8.compare(ApertureValue.f4).rawValue)
// -1 (ComparisonResult.orderedAscending)
print(ApertureValue.f8.stopsDifference(from: ShutterSpeedValue.oneSecondShutterSpeed))
// nil, since this isn't a valid comparison
print(ApertureValue.f8.compare(ShutterSpeedValue.oneSecondShutterSpeed).rawValue)
// -100 (ExposureComparisonInvalid), since this isn't a valid comparison
```
### Transforming Values
When transforming values, use the `-adding(_:)` method. Since you can't transform indeterminate values such as bulb shutter speeds or automatic values, this method can return `nil`. You can use the `isDeterminate` property to exclude such values from calculations.
In general, a postive stops value means "more light" or "a brighter image", and a negative value means "less light" or "a darker image".
```swift
let stops = ExposureStops(fromDecimalValue: 1.0)
let f8 = ApertureValue.f8
print(f8.adding(stops)) // f/5.6
let one250th = ShutterSpeedValue.oneTwoHundredFiftiethShutterSpeed
print(one250th.adding(stops)) // 1/125
let iso100 = ISOValue.iso100
print(iso100.adding(stops)) // ISO 200
let zeroEV = ExposureCompensationValue.zeroEV
print(zeroEV.adding(stops)) // 1 EV
```
## License
StopKit is licensed under the MIT license. For full details, see the [LICENSE](LICENSE) file.