https://github.com/hasnep/roc-turtle
🐢 Turtle graphics in Roc
https://github.com/hasnep/roc-turtle
roc roc-lang turtle turtle-graphics
Last synced: 2 months ago
JSON representation
🐢 Turtle graphics in Roc
- Host: GitHub
- URL: https://github.com/hasnep/roc-turtle
- Owner: Hasnep
- License: upl-1.0
- Created: 2024-08-10T13:52:05.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-11-15T14:25:24.000Z (6 months ago)
- Last Synced: 2025-01-21T09:27:21.407Z (4 months ago)
- Topics: roc, roc-lang, turtle, turtle-graphics
- Language: Roc
- Homepage: https://hasnep.github.io/roc-turtle
- Size: 300 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Roc Turtle
A pure Roc turtle library with no effects, the final drawing is converted to an SVG string and can be saved to a file for viewing.
## Usage
Add the `roc-turtle` package to your header.
```roc
app [main] {turtle: "..."}
```Import the `Turtle` module.
```roc
import turtle.Turtle
```Create a `Turtle` using the `Turtle.new` function.
```roc
turtle = Turtle.new {}
```Use functions like `Turtle.forward` and `Turtle.turn` to move the turtle.
```roc
path = turtle |> Turtle.forward 1 |> Turtle.turn (Num.pi / 4)
```When your drawing is done, use the `Turtle.toSvg` function to convert it into an SVG string which you can output to a file.
```roc
svgStr = Turtle.toSvg path { x: { from: -500, to: 500 }, y: { from: -500, to: 500 } }
```