Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/james-p-d/logo
A C# WinForms implementation of the educational programming language Logo with the addition of variables, evaluations and basic control functions (if/then/else/loops etc.)
https://github.com/james-p-d/logo
csharp educational-programming-language imperative-programming interpreter logo turtle variables winforms
Last synced: 17 days ago
JSON representation
A C# WinForms implementation of the educational programming language Logo with the addition of variables, evaluations and basic control functions (if/then/else/loops etc.)
- Host: GitHub
- URL: https://github.com/james-p-d/logo
- Owner: James-P-D
- License: mit
- Created: 2019-06-27T21:41:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-04T20:39:33.000Z (over 3 years ago)
- Last Synced: 2024-11-17T10:36:21.696Z (3 months ago)
- Topics: csharp, educational-programming-language, imperative-programming, interpreter, logo, turtle, variables, winforms
- Language: C#
- Homepage:
- Size: 4.51 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logo
An implementation of the educational programming language [Logo](https://en.wikipedia.org/wiki/Logo_(programming_language)) with the addition of variables, evaluations and basic control functions (`repeat`, `if..then..else`, `while`, `break`, `continue` etc.)![Screenshot](https://github.com/James-P-D/Logo/blob/master/screenshot.gif)
## Commands
Below is a quick overview of the available commands. For some sample programs, see the [examples](https://github.com/James-P-D/Logo/tree/master/src/Logo/Logo/examples) folder.
## Contents
1. [Basic Movements](#Basic-Movements)
2. [Colours and Pen Up/Down](#Colours-and-PenUp-PenDown)
3. [Variables](#Variables)
4. [Repeat Loops](#Repeat-Loops)
5. [If..Then..Else, Break and Continue](#If-Then-Else-Break-and-Continue)
6. [While Loops](#While-Loops)### Basic Movements
The turtle can be moved in four directions without turning:
```
forward X;
backward X;
left X;
right X;
```In each case `X` can be an integer literal, e.g. `forward 100;`, or can be a variable, e.g. `forward length;` (where `length` has been declared as a `number` variable), or it can be an evaluation consisting of integer literals and/or variables, e.g. `forward 2 * length;`.
It is also possible to rotate the turtle clockwise or anti-clockwise:
```
rightturn X;
leftturn X;
```Again, `X` can be an integer literal, a variable or an evaluation consisting of integers and variables.
It is also possible to manually set the `X` and `Y` positions, or the direction of the turtle:
```
setx X;
sety Y;
setdirection D;
```As usual, the parameter can be a integer literal, variable or evaluation. When setting the direction, the value `D` will wrap around `0` and `360`.
If you wish to simply centre the turtle and set the direction to upward (zero) we can use the following command:
```
centerturtle;
```We can toggle the displaying of the turtle with the following commands:
```
hideturtle;
showturtle;
```### Colours and PenUp PenDown
By default the turtle pen colour will always be black, but it is possible to set the [ARGB](https://en.wikipedia.org/wiki/RGBA_color_model) components:
```
setcolora X;
setcolorr X;
setcolorg X;
setcolorb X;
````X` can be an integer literal, a variable or an evaluation consisting of integers and variables, but the value will be capped to the range `0-255`.
By default the turtle will always draw lines as it moves across the canvas. If you wish to toggle whether the turtle pen is touching the canvas or not, you will need the following commands:
```
penup;
pendown;
```### Variables
Variables can be declared using the keyword `number` followed by a variable name.
```
number length;
```Once variables have been created, we can assign values to them with the assignment operator `=`:
```
length = 10;
```It is also possible to initialise variables:
```
number width = 15.8;
```We can also initialise variables with evaluations:
```
number area = length * width;
```Finally it is possible to create `boolean` variables:
```
boolean bool1;
boolean bool2 = false;
boolean bool3 = bool1 && bool2;
```### Repeat Loops
We can repeat a set of commands by using the `repeat` command:
```
repeat N {
Command1;
Command2;
..
CommandN;
}
```Where `N` can be an integer literal, variable or evaluation.
For example, to draw a square we might use the following:
```
repeat 4 {
forward 100;
rightturn 90;
}
```### If Then Else Break and Continue
The interpeter also supports `if..then..else` commands, plus the ability to `break` from loops or to `continue`.
For example, if we wished to draw a semi-circle we could use the following:
```
number counter = 0;
repeat 36 {
if(counter <= 18) {
forward 10;
rightturn 10;
} else {
break;
}
counter = counter + 1;
}
```### While Loops
The interpeter also supports `while` loops:
```
number counter = 0;
while (counter < 36) {
forward 10;
rightturn 10;
counter = counter + 1;
}
```