Giter Club home page Giter Club logo

turtle-roy's Introduction

Turtle Roy

A Roy programming/learning environment with Turtle Graphics, as in the Logo programming language.

Try it online: turtle-roy.heroku.com/

Turtle Roy API

fd 100                      | moves 100 pixels forward
lt 45                       | turns left 45 degrees
rt 90                       | turns right 90 degrees
penup                       | lifts the pen, no trace left when moving
pendown                     | lowers the pen again for drawing
setshape "rocket-large"     | changes the cursor. available (with and without -large): butterfly, car, fairy, formula, princess, rocket, turtle
clear                       | clear the paper and reset turtle to center
home                        | reset the turtle to center
say "wat"                   | speak!
print "x"                   | print to console
login "raimo"               | login as "raimo" (this is the author name in your saved work)
save "asdf"                 | save current work as "asdf"
open "asdf"                 | open saved work "asdf" (presuming you've saved with this name and current author name)
whoami                      | show the author name of the logged-in user (this is just saved in a cookie)
ls                          | list your saved works
play c                      | plays the note C    
play c 500                  | plays the note C for 500 milliseconds
play c*2                    | plays the note C2 (frequency = C * 2)
sequence [fd 100, rt 90]    | 100 pixels forward, then right turn
s [fd 100, rt 90]           | same as above
repeat 4 (say "hello")      | says "hello" 5 times
r 4 (say "hello")           | same as above
par [play c, play e]        | playes notes C and E in parallel

In addition to this, you may use the full Roy programming language.

Examples

Bunch of examples available in the demo menu. Some more stuff here.

Basic Turtle commands

fd 100
lt 90
rt 45

Square

let square = repeat 4 (sequence[fd 50, lt 90])
square

Flower

let flower = repeat 36 (rt 10, square)
flower

Math

3 + 4
3 / 4
let factorial n = if n==1 then 1 else n * (factorial n - 1)
factorial 12

Strings

"apple" ++ "sauce"
"apple" + 10 (won't compile)

Lists

range 1 99
times 100 "lol"
head [1,2,3]
tail [1,2,3]
concat [1,2,3] [4,5,6]
length [1,2,3]
empty []
let reverse xs = if (empty xs) then [] else concat (reverse (tail xs)) [head xs]
reverse [1,2,3]
sum [1,2,3]
map (\x -> x * 2) [1,2,3]
filter (\x -> x > 1) [1,2,3]
foldl (\x y -> x * y) 1 [1,2,3]

Running

./start

Credits

Thanks to Miikka "arcatan" Koskinen for creating tryroy, from where I shamelessly stole the Roy browser REPL.

Thanks to Brian McKenna for the Roy language and support.

See origins of the cursor images from src/main/webapp/images/image-sources.txt

turtle-roy's People

Contributors

jaakkosipari avatar miikka avatar olliwer avatar raimohanska avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.