Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tribalworldwidelondon/CassowarySwift
A Swift port of the Cassowary linear constraint solver
https://github.com/tribalworldwidelondon/CassowarySwift
cassowary constraint-solver swift
Last synced: 10 days ago
JSON representation
A Swift port of the Cassowary linear constraint solver
- Host: GitHub
- URL: https://github.com/tribalworldwidelondon/CassowarySwift
- Owner: tribalworldwidelondon
- License: bsd-3-clause
- Created: 2017-08-17T10:35:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-19T18:20:17.000Z (over 5 years ago)
- Last Synced: 2024-10-10T10:03:57.778Z (29 days ago)
- Topics: cassowary, constraint-solver, swift
- Language: Swift
- Homepage:
- Size: 42 KB
- Stars: 111
- Watchers: 3
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-swift - Cassowary - A linear constraint solving library using the same algorithm as AutoLayout. (Libs / Layout)
- awesome-swift - Cassowary - A linear constraint solving library using the same algorithm as AutoLayout. (Libs / Layout)
- awesome-swift - Cassowary - A Swift port of the Cassowary linear constraint solver (Layout [🔝](#readme))
- awesome-swift - Cassowary - A linear constraint solving library using the same algorithm as AutoLayout. (Libs / Layout)
README
# Cassowary Swift
[![Build Status](https://travis-ci.org/tribalworldwidelondon/CassowarySwift.svg?branch=master)](https://travis-ci.org/tribalworldwidelondon/CassowarySwift)
A Swift port of the Cassowary linear constraints solver. Tested on OS X, iOS and Linux.
# Example usage
```swift
let solver = Solver()let left = Variable("left")
let mid = Variable("mid")
let right = Variable("right")try solver.addConstraint(mid == (left + right) / 2)
try solver.addConstraint(right == left + 10)
try solver.addConstraint(right <= 100)
try solver.addConstraint(left >= 0)solver.updateVariables()
// left.value is now 90.0
// mid.value is now 95.0
// right.value is now 100.0try solver.addEditVariable(variable: mid, strength: Strength.STRONG)
try solver.suggestValue(variable: mid, value: 2)solver.updateVariables()
// left.value is now 0.0
// mid.value is now 5.0
// right.value is now 10.0```
# Documentation
[Documentation can be found on CocoaDocs](http://cocoadocs.org/docsets/Cassowary)# Acknowledgements
Cassowary Swift originally started as a direct port of [kiwi-java](https://github.com/alexbirkett/kiwi-java) by [Alex Birkett](https://github.com/alexbirkett)