Installation
Download or clone the CSharpLogo repository from https://github.com/syedhussim/CSharpLogo.git.
git clone https://github.com/syedhussim/CSharpLogo.git
Usage
The program accepts two command line arguments. The first argument is the full file path to the source code. The second argument is the path to the HTML output file.
dotnet run /path/to/source/code /path/to/output.html
Standard Commands
Command | Description |
---|---|
home | Return to the centre of the canvas. |
penup | Ink on the canvas is turned off. |
pendown | Ink on the canvas is turned on. |
setpencolor | Sets the pen colour. |
forward | Moves the cursor forward. |
right | Turns right. |
left | Turns left. |
repeat | Control flow function. Repeats code withing code block. |
Extended Commands
Command | Description |
---|---|
setcanvas | Sets the canvas width, height and background colour. |
randpencolor | Sets a random pen color. |
func | Creates a user defined function. |
Examples
To draw a square use the FORWARD and LEFT commands as shown below.
Listing 1
FORWARD 100
LEFT 90
FORWARD 100
LEFT 90
FORWARD 100
LEFT 90
FORWARD 100
The REPEAT command is used to repeat a block of code. The code sample below shows how to draw a square by repeating the FORWARD and LEFT commands.
Listing 2
REPEAT 4 [
FORWARD 100
LEFT 90
]