Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/epost/purescript-free-turtle

A toy turtle graphics interpreter based on the Free monad, in PureScript, with HTML Canvas graphics support.
https://github.com/epost/purescript-free-turtle

free-monad purescript turtle-graphics tutorial-code

Last synced: 12 days ago
JSON representation

A toy turtle graphics interpreter based on the Free monad, in PureScript, with HTML Canvas graphics support.

Awesome Lists containing this project

README

        

#+title: PureScript Free Turtle interpreter

A simple Turtle graphics system implemented using a ~Free~ monad, intended for educational purposes. It comes with an interpreter that translates programs in the Turtle language to HTML canvas graphics.

[[file:img/two-stars.png]]

#+BEGIN_SRC purescript
main :: Effect Context2D
main = CanvasInterpreter.render "turtleCanvas" do
color Purple
star

forward 40.0
left 100.0

color Red
star

star = do
penDown
right 144.0
forward 100.0
right 144.0
forward 100.0
right 144.0
forward 100.0
right 144.0
forward 100.0
right 144.0
forward 100.0
penUp
#+END_SRC

* Usage

In your shell, type:

: npm install
: npm run build
: npm run bundle

Then point your browser to [[./html/index.html]].