npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

xturtle

v1.2.0

Published

WebComponent to render a turtle canvas in web applications

Downloads

7

Readme

Turtle

Turtle is a way to create graphic elements on the screen with a cartesian plan(x, y) using commands, the original turtle was based on logo language that was used to move robots. Turtle is very popular to teach kids how to programming, and this library implements some of this turtle commands in javascrypt language to be used in any web application or even on jupyter notebook.

Install

$ yarn install
$ yarn build
$ yarn start

Add package on project

To use turtle component you just need to add this lib on your package json:

  "dependencies": {
    ...
    "turtle-component": "^0.9.2"
  }

or use yarn:

yarn add turtle-component

Installing on jupyter notebook

See README in ipyxturtle implementation.

How to Use

It's realy simple to use it, this turtle js lib is a HTML component so you justo need to add the x-turtle component to you HTML, like this:

image

the HTML params widht, heigth and canvas-class are the only ones that the component receives. The canvas-class sets a class to the drawing canvas, what is usefull if you want to add some styles or even make some changes on the canvas.

The component has a method called createTurtle that retuns a new turtle on the canvas screen

image

After use the create turtle the sprite of the turtle will pop up on the canvas, then just use the created turtle to execute the turtle commands, for example:

image

This way you cand draw many things on the screen, here down is a example:

with this code:

turtle.setLineColor('blue')
for(let i = 0; i < 20; i++){
    turtle.forward(i * 10)
    turtle.right(144)
}

you can draw this:

image

Have fun!

Turtle functions

  • forward(value): draw a line forward the size you define
  • backward(value): draw a line backward the size you define
  • setLineColor(color): changes the line color
  • circle(radius): creates a circle on the screen wiht the defined radius
  • rectangle(width, height): creats a retangle on the screen with the defined width and height
  • speed(value): Changes the draw speed
  • clear(): Cleans the canvas
  • right(angle): Add a defined angle to right
  • left(angle): Add a defined angle to left
  • setPosition(x, y): Changes the turtle position
  • getPosition(): Returns the turtle position
  • penUp(): Unses the drawing mode
  • penDown(): Sets the drawing mode
  • turtleCommandsList(actionList): Receives a Json list of commands, the list mus be on this format:
[
  { action: 'forwardAction',
    parameters: [100]
  },
  {
    action: 'leftAction',
    parameters: [90]
  },
  { action: 'forwardAction',
    parameters: [100]
  },
  {
    action: 'leftAction',
    parameters: [90]
  },
  { action: 'forwardAction',
    parameters: [100]
  },
  {
    action: 'leftAction',
    parameters: [90]
  },
  { action: 'forwardAction',
    parameters: [100]
  },
]

Note that the actions must have an Action suffix on the action name, and the parameters must be a list.