npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blava

v3.0.0

Published

Performant, artful blob generator 🎨

Downloads

25

Readme

Blava

Performant artful blob generator using canvas 📋

Install

Via npm, Yarn, pnpm

pnpm i blava

How to use

  1. Import with

    import { Blava, Point } from 'blava';

  2. Place a blank canvas element into a parent container. The canvas will be resized to cover the parent element, which is assumed to be square in aspect ratio

  3. Initialize the Blava object with new Blava(canvas) where canvas is a reference to the canvas element. An additional configuration object can also be included. Animation automatically begins. To toggle the animation, call Blava.pause and Blava.play

Configuration options

| parameter | default value | options | notes | | ------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | seed | undefined | Any string | A seed on which all random generation (such as movement, initial positioning, & gradient hue) will be based | | variance | {x:5,y:10} | Any object with x and y number parameters | The extent of movement in each direction | | gradient | 'auto' | 'auto' or an object with either from and to color string properties or from and to property objects, each containing a color color string property and a position object with x and y properties describing the position of the stop | The gradient fill of the Blava | | movementSpeed | 'slow' | One of ['molasses', 'slow', 'medium', 'fast', 'jelly'] or any number | The speed of movement in point animation. Typically any number between 0.000_05 and 0.01 works well | | points | null | null, an array of Points, or an array of objects with x and y number parameters | The points to build the Blava blob with | | pointCount | 6 | Any number | The number of points to build the Blava blob with. Does nothing if points parameter is supplied | | style | 'wave' | One of ['wave','blob'] | The style of Blava to generate. Does nothing if points parameter is supplied | | beforePaint | undefined | Any function | Function called before painting the Blava on the canvas. The points and path of the Blava are calculated by this step. First argument is the Blava instance | | afterPaint | undefined | Any function | Function called after painting the Blava on the canvas. First argument is the Blava instance |

Other notes

Canvas coordinates & animation

A Blava is generated on a canvas whose container element is assumed to be a square. Points are placed on a 100×100 grid, with {x: 0, y: 0} being the top left corner of the canvas. The variance setting determines the maximum distance the point can travel vertically or horizontally during animation (assuming the Point's animated property for that dimension is set to true)

Points

A custom Point class is included to track positioning and per-direction animation state of each point in the Blava. The constructor takes an x and y position as well as an optional configuration object. The configuration object can have an animated property with either a boolean to determine whether the Point is animated at all or an object with x and y properties to set animation state per dimension

Hooks

The beforePaint and afterPaint configuration options allow for a function before and after the Blava paint operation respectively. Both functions have full access to the Blava instance as the first passed argument. Point calculation is completed before running either function, so they can be manipulated before or after the paint operation.