node-turtle

A turtle library for javascript

Usage no npm install needed!

<script type="module">
  import nodeTurtle from 'https://cdn.skypack.dev/node-turtle';
</script>

README

node-turtle

A node-js wrapper for python's turtle library. turtle-js was meant to help teach javascript as a standalone language.

Installation

npm install node-turtle
# or
yarn add node-turtle

Example

const { Turtle } = require('node-turtle')

async function main() {
    let turtles = []
    for (let i = 0; i < 15; i++) {
        let turtle = await Turtle()
        await turtle.penup()
        await turtle.goto(-100, -50 + i * 15)
        await turtle.color(Math.random(), Math.random(), Math.random())
        await turtle.pendown()
        await turtles.push(turtle)
    }
    while (true) {
        for (turtle of turtles)
            await turtle.forward(Math.floor(Math.random() * 5))
    }
}

main()