npm.io
1.0.3 • Published 4 years ago

rainbow-square

Licence
MIT
Version
1.0.3
Deps
1
Size
8 kB
Vulns
0
Weekly
0

rainbow-square

Create a dataURL for a square with a rainbow gradient.

GitHub release Build Status codecov Codacy Badge

rainbow-square

Install

You can install via npm or yarn.

npm

npm install --save rainbow-square
yarn
yarn add rainbow-square

Documentation

This documentation is written in TypeScript, however this library works fine in vanilla JavaScript too.

Usage

The async function will return a dataURL which can be used in the src attribute of an img tag.

import { rainbowSquare } from 'rainbow-square';

async function myFn(): Promise<void> {
  const image = document.createElement('img');

  img.src = await rainbowSquare(256);

  document.body.appendChild(img);
}

void myFn();

You can also provide a height if you want to generate an rainbow gradient that isn't a square.