A loader for your site that draws Lissajous curves
- Authenticate to GitHub Packages
- Create file
.npmrc
in your repository and add the following:@okcid:registry=https://npm.pkg.github.com
npm i @okcid/lissajous-loader
HTML:
<html>
<head>
</head>
<body>
<canvas id="loader" width="50" height="50" />
</body>
</html>
Javascript:
import LissajousLoader from 'lissajous-loader';
const canvas = document.getElementById('loader');
const loader = new LissajousLoader(canvas, {
xFrequency: 3,
yFrequency: 2,
delta: Math.PI / 2,
});
loader.start();
callApi()
.then(() => {
loader.stop();
});
const loader = new LissajousLoader(canvas, props);
-
canvas
– instance ofHTMLCanvasElement
to draw the loader on;
Note: canvas is recommended to be square (height
property should equal thewidth
property) -
props
– an object with loader propsNote: A and B are both equal to 1 for simplicity
Note: ❗ means required prop, ❓ – optional prop
loader.start();
This method starts the drawing cycle of a loader
loader.stop();
Stops the drawing cycle of a loader and clears the canvas
loader.clear();
An utility method to clear the canvas