0.0.2 • Published 8 years ago

nayuki-canvas v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Nayuki Canvas

Build Status Dependency Status codecov

Nayuki Canvas a floating node HTML5 canvas with zero dependencies and lovably simple setup.

Screenshot software

Install

$ npm install nayuki-canvas --save

Setup (as global)

<script src="./path/to/node_modules/nayuki-canvas/dist/nayuki-canvas.min.js">

Also consumable as Javascript Module and AMD

Usage

var canvas = document.getElementById('canvas');
var config = {};
var myCanvas = nayukiCanvas(canvas, config).start();

API

Configuration Options

NameTypeDefaultDescription
extraEdgesNumber20Recommendation on how many edges should appear
nodeCountNumber70Amount of nodes to render
networkString'balanced'Other network styles: mesh & wheel
repulsionNumber1Speed at which nodes move from one another
borderFadeNumber-0.02Place where nodes fade on canvas edge
fadeInRateNumber0.06Rate of nodes fade on create
fadeOutRateNumber0.03Rate of nodes fade on destroy
frameIntervalNumber20Speed of canvas
backgroundArray/String'#0275d8', '#055396'String and array HEX values
gradientString'radial'Gradient styles: linear, radial
nodeColorString'#f1f1f1'HEX value of node color
edgeColorString'#b4b4b4'HEX value of edge color
edgeSizeNumber0.7Thickness of edge
nodeSizeNumber900Size of node

Starting & Stopping

myCanvasInstance.start(); // Start Canvas
myCanvasInstance.stop(); // Freeze Frame™

Updating

myCanvasInstance.nodeSize = 450;
// On next frame render nodes will have new size

Removing

myCanvasInstance.destroy();

Checking Browser Support

if (nayukiCanvas.isSupported) {
  // canvas time
}

Manual Frame Rendering

myCanvasInstance.start().stop(); // queue and cancel frame render
myCanvasInstance.next(); // manually draw next frame

Created by

Matt JensenNayuki
Matt JensenNayuki

Version

  • Version 0.0.1

License