Skip to content

♋ Interactive Particle / Nest System With JavaScript and Canvas, no jQuery.

License

Notifications You must be signed in to change notification settings

stefenson/canvas-nest.js

 
 

Repository files navigation

canvas-nest.js

A nest backgroud of website draw on canvas. 中文 Readme 帮助文档.

npm npm npm gzip

npm i --save canvas-nest.js

Feature

  • No need jQuery.
  • Light, only 2 Kb.
  • Easy to use, even you are not a web developer.
  • Modular & area render.

Usage

  • Script tag

Insert the code below between <body> and </body>.

<script src="dist/canvas-nest.js"></script>

Suggest before the tag </body>, like below:

<html>
<head>
	...
</head>
<body>
	...
	...
	<script src="dist/canvas-nest.js"></script>
</body>
</html>

Then ok! Please do not add the code in the <head> </head>.

  • Module usage (Area render)

npm i --save canvas-nest.js

Or import the umd package use script tag.

There is only one API, use it like:

import CanvasNest from 'canvas-nest.js';

const config = {
  color: '255,0,0',
  count: 88,
};

// render nest on element with config.
const cn = new CanvasNest(element, config);

// destroy
cn.destroy();

Config

  • color: the canvas line color, default: '0,0,0'; the color is (R,G,B).
  • opacity: the opacity of line (0~1), default: 0.5.
  • count: the number of lines, default: 99.
  • zIndex: the index of z space, default: -1.

Example:

<script type="text/javascript" color="0,0,255" opacity='0.7' zIndex="-2" count="99" src="dist/canvas-nest.js"></script>

Or

{
  color: '0,0,255',
  opacity: 0.7,
  zIndex: -2,
  count: 99,
};

Related projects

Used by

License

MIT@hustcc.

About

♋ Interactive Particle / Nest System With JavaScript and Canvas, no jQuery.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 91.1%
  • HTML 8.9%