A turtle graphics (a key feature of the Logo ) engine written in Swift.
A turtle graphics (a key feature of the Logo engine written in Swift.
The commands were implemented with reference to the turtle in Python 3 standard libraries.
// Turtle Star!
🐢.beginFill()
36.timesRepeat {
🐢.forward(200)
🐢.left(170)
}
🐢.endFill()
// Instantiate a `Tortoise`
let 🐢 = Tortoise()
// Instantiate `ImageCanvas` and add the tortoise
let canvas = ImageCanvas(size: Vec2D(300, 300))
canvas.add(🐢)
// Command 🐢
🐢.right(90)
🐢.forward(100)
// Get drawn `CGImage`
let cgImage = canvas.cgImage
TortoiseGraphics.xcworkspace
in Xcode.TortoiseGraphics
scheme for iOS Simulator.Playground
in project navigator.TortoiseGraphics.playgroundbook.zip
from here.TortoiseGraphics.playgroundbook
file to your iPad by AirDrop.Tortoise
ImageCanvas
Shape
Color
Vec2D
Speed
forward()
, fd()
backword()
, back()
, bk()
right()
, rt()
left()
, lt()
setPosition()
, setPos()
, goto()
setX()
setY()
setHeading()
, setH()
home()
circle()
position
, pos
towards()
xcor
ycor
heading
distance()
penDown()
, pd()
, down()
penUp()
, pu()
, up()
penSize()
width()
isDown
penSize
width
penColor()
penColor
fillColor()
fillColor
filling
beginFill()
endFill()
reset()
clear()
showTortoise()
, st()
hideTortoise()
, ht()
isVisible
shape()
shape
Int.timesRepeat() {}
random()
degrees()
radians()
colorMode()
,colorMode
PlaygroundCanvas
PlaygroundCanvasLiveView
SwiftPlaygroundCanvas
LiveViewController
github "temoki/TortoiseGraphics"
pod 'TortoiseGraphics'
TortoiseGraphics is released under the MIT license. See LICENSE for details.