Skip to content

Latest commit

History

History
76 lines (51 loc) 路 2.23 KB

File metadata and controls

76 lines (51 loc) 路 2.23 KB

馃悽 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.