Skip to content

tkausch/TurtleGeometry

Repository files navigation

🐢 Geometry in Swift

Swift Xcode Swift Playgrounds License

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.

Example Usage

// 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()
    }
}

Result

Use in Playgrounds

Open Project in Xcode

  1. Open TurtleGeometry.xcworkspace in Xcode.
  2. Build TurtleGeometry-Package scheme for iOS Simulator.
  3. Select Playground in project navigator.
  4. Open Introduction.playgroundin playgrounds
  5. Discover more samples in Turtle Geometry Book

Integrate Library with Swift-Package-Manager

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

Requirements

  • Swift 5.2 (Xcode 11.4.2)
  • iOS 13.0 or later

Remaining Work

  • carthage support
  • cocoa pods support
  • ipad playground support

License

Turtle Geometry is released under the GPL-3.0 license. See LICENSE for details.

About

Swift as a Medium for Exploring Mathematics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages