Socket
Socket
Sign inDemoInstall

canvas-effects

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    canvas-effects

modular canvas visualizations


Version published
Maintainers
1
Created

Readme

Source

canvas-effects

npm version

BETA: Expect everything to change.

A Javascript library of canvas visualizations.

Getting Started

Download and install the latest version from npm:

npm install --save canvas-effects

Or you can test the alpha from Github:

npm install --save getmicah/canvas-effects

Then import the effects you want into your project:

import { Efect } from 'canvas-effects';

const foo = new Effect({
	// ...
});

Config

These are global parameters that must be included in the config of every effect.

container

A CSS selector that represents a <div> element.

const foo = new Effect({
	container: '#selector'
});
width / height

Declares the desired width and height of the element.

const foo = new Effect({
	width: 500,
	height: 500
});

const bar = new Effect({
	width: '100%',
	height: 400
});

Constellations

Demo

Instantiate:

import { Constellations } from 'canvas-effects';

const foo = new Constellations({
	// ...
});

Config

All of the following config options are optional and contain default values.

seed

Changes the amount of random points generated based on the area of the element. A smaller number will produce more points, resulting in less performance.

const foo = new Constellations({
	seed: int // Default: 8000
});
point

Changes the properties of the randomly generated points on the canvas which act as vertices for the constellations.

const foo = new Constellations({
	point: {				// Defaults:
		color: String,		// '#000000'
		radius: [max,min],	// [4, 2]
		speed: [max,min]	// [0.2, 0.1]
	}
});
line

Changes the properties of lines that connect each point. The code generates every line then programmatically decides whether to render it.

const foo = new Constellations({
	line: {					// Defaults:
		color: [r,g,b,a],	// [0, 0, 0, 1]
		fade: int,			// 0.05
		max: int,			// 100
		width: int			// 1
	}
});

Example

import { Constellations } from 'canvas-effects';

const foo = new Constellations({
	container: '#bar',
	width: '100%',
	height: 400,
	seed: 4000,
	point: {
		color: 'rgba(0,0,255,0.5)',
		radius: [8,4],
		speed: [0.8,0.4]
	},
	line: {
		color: [255,0,0,0.1],
		fade: 0.01,
		max: 150,
		width: 4
	}
});

License

Everything is under the MIT License.

Copyright (c) 2017 Micah Cowell

FAQs

Last updated on 26 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc