Code Monkey home page Code Monkey logo

punktjs's Introduction

punktjs travis ci travis ci

Draw Shapes in the Terminal

Usage

import { Circle, Path, Point, Group } from './index'
import { TerminalRenderer as Renderer } from './TerminalRenderer'

// create a new Path 
var path = new Path([[3, 5], [10, 12], [20, 12], [40, 42]])

// create a new Circle at x:10, y:5, r:10
var circle = new Circle([10, 5], 10)
circle.center = [10, 10]

// create Groups at position x:15, y:15; x:20, y:20
var group1 = new Group([15, 15])
var group2 = new Group([20, 20])

group1.addChild(circle)
group2.addChild(group1)

//create renderer and attach shapes
var renderer = new Renderer()
renderer.attach(group1, {color: [122, 222, 56]})
renderer.attach(circle, {color: [200, 30, 23]})

// or attach all elements in a group
renderer.attachAll(group2)

// listen for keyboard input
renderer.handleInput()

// move the Path
renderer.on('key.left', () => {
    path.position.x += 1
})

//rotating the circle group
setInterval(() => {
    group1.rotation += 1
    renderer.render()
}, 150)

See /examples for more examples 😅

Examples

bildschirmfoto 2017-10-23 um 10 43 55

Show Path and Handles

bildschirmfoto 2017-10-23 um 10 50 16

Rotate Path

bildschirmfoto 2017-10-23 um 10 52 22

Display Intersections

bildschirmfoto 2017-10-23 um 10 52 42

punktjs's People

Contributors

glumb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

punktjs's Issues

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.