Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twotau/stickfigure.js
A JavaScript library for creating stick figures and drawing them on <canvas>
https://github.com/twotau/stickfigure.js
Last synced: 14 days ago
JSON representation
A JavaScript library for creating stick figures and drawing them on <canvas>
- Host: GitHub
- URL: https://github.com/twotau/stickfigure.js
- Owner: TwoTau
- Created: 2015-09-28T00:49:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-20T04:04:02.000Z (about 9 years ago)
- Last Synced: 2023-02-27T18:25:47.921Z (over 1 year ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# StickFigure.js
A JavaScript library for creating stick figures and drawing them on <canvas>To use this library, download it to your scripts folder and add a link to it in your HTML:
```html```
First, you need to get your canvas' context.
```javascript
var canvas = document.getElementById("demo");
var ctx = canvas.getContext("2d"); // the canvas context
```Create a stick figure:
```javascript
var options = {}; // You can have several options here
var stick = new StickFigure(options);
```Draw the stick figure:
```javascript
stick.draw(ctx);
```You can change the the length and angle of the stick figure's limbs.
For example:
```javascript
stick.arms.left.elbow.angle = -50;
stick.arms.left.hand.angle = 90;stick.arms.right.elbow.angle = -5;
stick.arms.right.hand.angle = 90;stick.legs.right.knee.angle = 30;
stick.legs.right.foot.angle = -65;stick.head.center.y = 400;
```![StickFigure.js example](http://twotau.github.io/img/stickfigurejsexample.png)
[View a demo here!](http://twotau.github.io/demo/stickfigure.html)
[View the demo source](https://github.com/TwoTau/twotau.github.io/blob/master/demo/stickDemo.js)