This Swift framework makes it surprisingly easy to start creating amazing shapes using a turtle. It is a turtle graphics engine written in Swift.
The commands and samples were implemented with reference to the book Turtle Geometry. In that book you will also find a lot of interesting samples.
// Create your own command
extension Turtle {
func myCommand() -> Self {
// Basic Commands
forward(100).right(90)
forward(100).right(90)
forward(50).right(90)
forward(50).right(90)
forward(100).right(90)
forward(25).right(90)
forward(25).right(90)
forward(50)
return self
}
}
// Create image with runner
let image = TurtleRunner().run() { 🐢 in
for _ in 1...4 {
🐢.myCommand()
}
}
- Open
TurtleGeometry.xcworkspace
in Xcode. - Build
TurtleGeometry-Package
scheme for iOS Simulator. - Select
Playground
in project navigator. - Open
Introduction.playground
in playgrounds - Discover more samples in Turtle Geometry Book
To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency
and enter this repository URL: https://github.com/tkausch/TurtleGeometry
- Swift 5.2 (Xcode 11.4.2)
- iOS 13.0 or later
- carthage support
- cocoa pods support
- ipad playground support
Turtle Geometry is released under the GPL-3.0 license. See LICENSE for details.