Skip to content

Latest commit

 

History

History
112 lines (72 loc) · 2.27 KB

README.md

File metadata and controls

112 lines (72 loc) · 2.27 KB

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.