Giter Site home page Giter Site logo

lissajous-loader's Introduction

@okcid/lissajous-loader

A loader for your site that draws Lissajous curves

lissajous-loader-demo

Installation

  1. Authenticate to GitHub Packages
  2. Create file .npmrc in your repository and add the following:
    @okcid:registry=https://npm.pkg.github.com
    
  3. npm i @okcid/lissajous-loader

Example

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();
    });

API

constructor

const loader = new LissajousLoader(canvas, props);
  • canvas – instance of HTMLCanvasElement to draw the loader on;
    Note: canvas is recommended to be square (height property should equal the width property)

  • props – an object with loader props

    Note: A and B are both equal to 1 for simplicity
    Note: ❗ means required prop, ❓ – optional prop

    Name Type Default Description
    xFrequency number
    yFrequency number
    delta number , it is better to be a fraction of Pi (e.g. Pi/2, Pi/6, etc)
    step number 0.05 A step for t param – the less it is, the more accurate the curve is
    padding number 16 Padding inside canvas element
    colour string 000000 HEX code of lines colour
    lineWidth number 1 The width of the curve's line
    pause number 1000 The time to wait before erasing the curve

start

loader.start();

This method starts the drawing cycle of a loader

stop

loader.stop();

Stops the drawing cycle of a loader and clears the canvas

clear

loader.clear();

An utility method to clear the canvas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.