PLOGO/README.md

121 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

2021-01-21 09:14:14 +00:00
# PLOGO
Purchase LOGO
2021-02-07 09:49:20 +00:00
(currently named for my uni).
2021-01-21 09:14:14 +00:00
A toy language.
A kind of LOGO-like DSL built in the p5.js library.
2021-01-29 18:39:23 +00:00
This is a rudimentary proof of concept right now with globals and without implementing classes. To write loops or *subroutines* one must use regular javascript.
2021-01-21 09:14:14 +00:00
2021-02-14 07:47:11 +00:00
![example logo program image](examples/simple-logo/simple-logo.jpg)
2021-01-29 18:54:53 +00:00
2021-01-21 09:18:38 +00:00
## How to Use
Put your code inside the turtle function in turtle.js
## Reference Commands
2021-01-21 09:14:14 +00:00
2021-01-29 18:39:23 +00:00
### Movement
```
forward(n)
2021-01-21 09:14:14 +00:00
```
2021-01-29 18:39:23 +00:00
move n pixels ahead
2021-01-21 09:14:14 +00:00
2021-01-29 18:39:23 +00:00
```
back(n)
```
move n pixels back
2021-01-21 09:14:14 +00:00
2021-01-29 18:39:23 +00:00
```
left(Δ)
```
turns Δ degrees to the left
2021-01-21 09:14:14 +00:00
2021-01-29 18:39:23 +00:00
```
right(Δ)
```
turns Δ degrees to the right
2021-01-21 09:14:14 +00:00
2021-02-07 08:14:01 +00:00
```
setpos(x,y)
```
moves turtle to x,y pixel coordinate. 0,0 is top left of window.
2021-01-29 18:39:23 +00:00
### Drawing
2021-01-21 09:14:14 +00:00
2021-01-29 18:39:23 +00:00
```
penup()
```
Going forward, Turtle will stop drawing a line with movement commands
2021-01-21 09:14:14 +00:00
2021-01-29 18:39:23 +00:00
```
pendown()
```
Turtle will start drawing lines tracing route. **By default, pendown is on / true**
```
penColor('colorName')
```
penColor takes any color word: purple, grey, blue, etc. **The color name must be in quotes.**
2021-02-15 01:55:26 +00:00
Alternatively, a HTML color name, like #ff4d4d, may be specified in quotes. Example: ```penColor('#ff4d4d')```
2021-01-21 09:14:14 +00:00
2021-01-29 18:39:23 +00:00
Alternatively, a RGB color or RGBA color with transparency can be specified, with *color*. Example: ```penColor(color(255,0,255))```. See transparency example in examples section below.
```
penSize(n)
```
Width of pen in pixels
2021-02-07 09:39:17 +00:00
```
retro()
```
Adds a retro filter on the entire drawing. This command can be called anywhere and filter is always applied at the end of the program.
2021-02-14 07:47:11 +00:00
```
noConsole()
```
Turns off the default onscreen display of the program listing.
2021-01-29 18:39:23 +00:00
### Randomness
2021-01-21 09:14:14 +00:00
```
2021-01-29 18:39:23 +00:00
randint(n)
```
or
2021-01-21 09:14:14 +00:00
2021-01-29 18:39:23 +00:00
```
randint()
```
Returns a random int between 0 and n. Specifying a value is optional. If no input *n*, the default is between 0 and 100. Example: ```forward(randint(30))```
## Examples
2021-02-14 07:51:20 +00:00
See examples folder.
2021-02-14 07:47:11 +00:00
2021-02-14 07:51:20 +00:00
![simple logo example](examples/simple-logo/simple-logo.jpg)
2021-01-29 18:39:23 +00:00
2021-02-14 07:51:20 +00:00
![color walker](examples/color-walker/color-walker.jpg)
2021-02-07 08:16:24 +00:00
2021-02-14 07:51:20 +00:00
![retro random walker](examples/retro-random-walker/retro-random-walker.jpg)
2021-02-07 08:16:24 +00:00
### Updates
2021-02-14 07:51:20 +00:00
##### 2021-02-14
2021-02-07 08:16:24 +00:00
2021-02-14 07:47:11 +00:00
- Added onscreen console print of commands (on by default) and noConsole() to turn off
- Added more example files
##### 2021-02-07
2021-02-07 08:25:30 +00:00
- Re-render turtle() after screen resizing
2021-02-07 08:16:24 +00:00
- Added new setpos(x,y) function to move turtle to a position. A path will be drawn if the pen is currently down.
2021-02-07 09:39:17 +00:00
- add retro() command for retro filter.