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

bgsvg

v1.3.1

Published

Generate beautiful random SVG backgrounds.

Downloads

31

Readme

Random SVG background generator

Generate beautiful random SVG backgrounds on Node.js runtime.

CI NPM Version NPM Downloads

Installation

npm i -S bgsvg
# or
yarn add bgsvg

Supported SVG backgrounds

Meteors

import { meteors } from "bgsvg";

const svg = await meteors({
  width: 800,
  height: 300,
  background: {
    colors: ["#000000", "#13137f"],
  },
  color: "#ba8003",
  densityX: 30,
  densityY: 2,
  thickness: 4,
  bidirectional: true,
  output: {
    type: "svg",
  },
});

console.log(svg);
// <svg xmlns="http://www.w3.org/2000/svg" width="800" height="300" viewBox="0 0 800 300"...

| Option | Default value | Description | | ------------- | ------------- | ------------------------------------ | | width | - | Width of the SVG | | height | - | Height of the SVG | | background | - | Background of the SVG | | color | - | Color of the meteors | | densityX | 30 | Average density of meteors on X-Axis | | densityY | 2 | Average density of meteors on Y-Axis | | thickness | 4 | Thickness of meteors | | bidirectional | true | Show meteors falling and rising | | output | {type: 'svg'} | Output format |

SVGs can have a solid color or a gradient background depending on the value of the background option.

export type CanvasBackground =
  | string
  | {
      x1?: string;
      y1?: string;
      x2?: string;
      y2?: string;
      colors: [string, string];
    };

You can generate SVG, PNG, JPEG, and Webp image based on the output option. When the output format is not SVG, then an image Buffer is returned.

type OutputTypeSvg = { type: "svg" };
type OutputTypePng = { type: "png" };
type OutputTypeWebp = { type: "webp" };
type OutputTypeJpeg = { type: "jpeg"; quality?: number };

rain

import { rain } from "bgsvg";

const svg = await rain({
  width: 800,
  height: 300,
  background: {
    colors: ["#27274c", "#121242"],
  },
  color: "#8f97c1",
  densityX: 20,
  densityY: 15,
  thickness: 1,
  randomness: 4,
});

console.log(svg);
// <svg xmlns="http://www.w3.org/2000/svg" width="800" height="300" viewBox="0 0 800 300"...

| Option | Default value | Description | | ---------- | ------------- | ---------------------------------------------- | | width | - | Width of the SVG | | height | - | Height of the SVG | | background | - | Background of the SVG | | color | - | Color of the rain drops | | densityX | 20 | Average density of drops on X-Axis | | densityY | 15 | Average density of drops on Y-Axis | | thickness | 1 | Thickness of the drop | | randomness | 4 | Randomness of the drops (more value, the less) | | output | {type: 'svg'} | Output format |


Development

Installation

yarn install

Preview server

yarn preview

This commands starts an express server at http://localhost:3003 to display how the SVGs would look like.

Test

yarn test