Functions
The following functions are available globally.
-
Do nothing.
Declaration
Swift
public func pass() -> TurtleCommand
-
Center the turtle.
Declaration
Swift
public func center() -> TurtleCommand
-
Reset the direction of the turtle.
Declaration
Swift
public func resetHeading() -> TurtleCommand
-
Set the direction of the turtle.
Declaration
Swift
public func setHeading(_ degree: Int) -> TurtleCommand
-
Set the position of the turtle.
Declaration
Swift
public func setPosition(_ x: Int, _ y: Int) -> TurtleCommand
-
Move the turtle without drawing a line.
Declaration
Swift
public func penUp() -> TurtleCommand
-
Move the turtle with drawing a line.
Declaration
Swift
public func penDown() -> TurtleCommand
-
Turn left to the given angle.
Declaration
Swift
public func left(_ angle: Int) -> TurtleCommand
Parameters
angle
The angle.
-
Turn right to the given angle.
Declaration
Swift
public func right(_ angle: Int) -> TurtleCommand
Parameters
angle
The angle.
-
Move forward.
Declaration
Swift
public func forward(_ length: Int) -> TurtleCommand
Parameters
length
How long do we move.
-
Run a loop.
Declaration
Swift
public func loop(_ repeatCount: Int, @TurtleBuilder builder: () -> [TurtleCommand]) -> TurtleCommand
Parameters
repeatCount
How many times do we repeat.
builder
The commands to run.
-
Set a macro.
Declaration
Swift
public func setMacro(_ name: String, @TurtleBuilder builder: () -> [TurtleCommand]) -> TurtleCommand
Parameters
name
Name of the macro.
builder
The commands to run.
-
Play a macro.
Declaration
Swift
public func playMacro(_ name: String) -> TurtleCommand
Parameters
name
Name of the macro.