Skip to content
forked from gitfaf/canvas-js

HTML 5 Canvas library for easy development.

License

Notifications You must be signed in to change notification settings

f0c1s/canvas-js

 
 

Repository files navigation

Build Status


NPM


canvas-js

Library for easy HTML5 canvas development.

Usage

    npm i -S canvas-js

    # or just grab required .js file

Circle API

jsfiddle older API

  var circle = new Circle();
  // context is 2D context of the canvas element of interest.
  // pattern is fillStyle
  // radius is a number
  // at finally fills the circle at x, y co-ordinates.
  circle.in(context).fillWith(pattern).of(radius).fillAt(x, y);
  var circle = new Circle();
  // context is 2D context of the canvas element of interest.
  // pattern is {strokePattern: pattern|gradient|color, lineWidth: number}
  // radius is a number
  // at finally draws the circle (outline/perimeter) at x, y co-ordinates.
  var options = { strokePattern: 'red', lineWidth: 3 };
  circle.in(context).drawWith(options).of(radius).drawAt(x, y);

NodeJS example

  var canvas = require('canvas-js-lib')

  canvas
  { Circle: [Function: Circle] }

  var c = new canvas.Circle()
  undefined

  c
  { startAngle: 0,
    endAngle: 6.283185307179586,
    antiClockwise: false }

  c.in('context')
  { startAngle: 0,
    endAngle: 6.283185307179586,
    antiClockwise: false,
    context: 'context' }
  >

Chaining is awesome

in, *With, of and *At return the circle object, thus chaining is possible.

License

MIT © Anubhav Saini 2016 - 2018

About

HTML 5 Canvas library for easy development.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.2%
  • HTML 5.8%