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) -> TurtleCommandParameters
angleThe angle.
-
Turn right to the given angle.
Declaration
Swift
public func right(_ angle: Int) -> TurtleCommandParameters
angleThe angle.
-
Move forward.
Declaration
Swift
public func forward(_ length: Int) -> TurtleCommandParameters
lengthHow long do we move.
-
Run a loop.
Declaration
Swift
public func loop(_ repeatCount: Int, @TurtleBuilder builder: () -> [TurtleCommand]) -> TurtleCommandParameters
repeatCountHow many times do we repeat.
builderThe commands to run.
-
Set a macro.
Declaration
Swift
public func setMacro(_ name: String, @TurtleBuilder builder: () -> [TurtleCommand]) -> TurtleCommandParameters
nameName of the macro.
builderThe commands to run.
-
Play a macro.
Declaration
Swift
public func playMacro(_ name: String) -> TurtleCommandParameters
nameName of the macro.
Functions Reference