GithubHelp home page GithubHelp logo

skx / turtle Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 2.0 603 KB

A simple turtle-implementation, using FORTH as a scripting-language

Forth 15.37% Go 69.87% Shell 14.76%
golang scripting-language forth forth-like scripting-engine go

turtle's Introduction

turtle

This repository contains a trivial implementation of a turtle-graphics thing.

We've embedded a simple FORTH Interpreter and we use that to allow the user to run scripts to control the standard turtle.

Usage

Run the application with the path to a script:

  ./turtle ./foo.in

The generated output will be saved in turtle.png, and an animation will be saved alongside it as turtle.gif:

Rendered output of _examples/squares.4th:

Result

Animated output of _examples/squares.4th, showing how it was created:

Result Animated

You can find example scripts beneath _examples/

Words

The following words are defined in words.go (and connected to the interpreter in main.go):

  • direction
    • Pop one word from the stack, set the direction to that value.
  • forward
    • Pop one word from the stack, move that much forward.
  • move
    • Pop two words off the stack, move to the specified coordinates.
    • Note move is like a teleport, there is no drawing involved.
  • pen
    • Pope one word from the stack, if 0 lift the pen, else lower it.
    • Drawing only occurs when the pen is down.
  • save
    • Saves the current state of the paper, and the animation of how we got there.
  • turn
    • Pop one word from the stack, increase the movement direction by that many degrees.

Github Setup

This repository is configured to run tests upon every commit, and when pull-requests are created/updated. The testing is carried out via .github/run-tests.sh which is used by the github-action-tester action.

turtle's People

Contributors

skx avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dfischer

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.