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

react-random-shapes

v0.6.2

Published

Create a random, wavy svg image.

Downloads

105

Readme

react-random-shapes

Wave

Create random, wavy svg shapes. Two available shapes as of now are:

NPM JavaScript Style Guide

Note: in v0.4.0, the "core" component was factored out to the random-shapes package.

Demo

A quick demo is here.

You can also see the components used on my site at both the top of the page and in the footer.

Install

npm install --save react-random-shapes

Example Usage

import React from 'react'

import { RandomHLine, RandomBlob } from 'react-random-shapes'

export default function Example() {
  return(
    <React.Fragment>
      <RandomHLine width={600} height={300} />
      <RandomBlob size={500} />
    </React.Fragment>
  )
}

RandomHLine

Generate a horizontal line (going roughly from left to right). width and height attributes are required.

Options

Options available are:

  • numLines = 1 Number of random lines to be shown.
  • leftPos = 0.5*height Vertical position of the left handle.
  • rightPos = 0.5*height Similar to leftPos.
  • posWindowSize = 0.2*height Size of the square in which the control points could wiggle around.
  • angleWindowSize = Math.PI/3 Size of the window in which the angle of the control line (measured from the control point) could wiggle around.
  • numControls = 2 Number of control points the line should have.
  • styleMid = {fill: "transparent", stroke: "black"} Style of the mid-line part. For different styles for each line, use an array of style objects.
  • styleTop = "none" Style of the top part.
  • styleBottom = "none" Style of the bottom part.
  • classNameTop = "" Class name for the top part.
  • classNameBottom = "" Class name for the bottom part.
  • classNameMid = "" Class name for the mid-line part.
  • seed = "" Set a seed string for the pseudorandom number generator.
  • debug = false Show the handles and control points, as well as console printouts for debug purpose.

Overriding

For more flexibility, you could "override" these points by adding the override attribute. This should be an array of the same length as the number of control points (the length of the override array will override if this is not true.) Each entry represents the override for each control point. If the entry is null, undefined, or "auto", there will be no overriding. To override, the entry must be an object with 3 possible keys: x, y, and angle. Each key's value will specify the override mode for that control point. There are 4 possible modes:

  • null, undefined, or "auto"
  • ["p", value]: specify the exact value of that key.
  • ["w", value]: specify the size of the window while having the center position automatically adjusted.
  • ["r", l_bound, u_bound]: specify the lower and upper boundries for that key.

Below is an example of an override array.

override = [
  {
    angle: ["r", 0, Math.PI / 4]
  },
  "auto",
  "auto",
  {
    x: ["p", 500],
    y: ["r", 10, 15] 
  },
  "auto"
]

RandomBlob

Generate a blob (circle-ish shape). size attribute is required.

Options

Options available are:

  • numBlobs = 1 Number of blobs to be drawn.
  • numControls = 3 Number of control points the blob should have.
  • posWindowSize = 0.1*size Radius of the circle in which the control points could wiggle around.
  • angleWindowSize = Math.PI/3 Size of the window in which the angle of the control line could wiggle around.
  • handleWindowSize = 0.5
  • style = {fill: "grey"} Style of the blob.
  • className = "" Class name for the blob.
  • seed = "" Set a seed string for the pseudorandom number generator.
  • debug = false Show the handles and control points, as well as console printouts for debug purpose.

Todo's

  • Accept required attributes as strings.
  • For RandomHLine, calculate slope based on two closest fixed points.
  • Add API that will generate random, wavy svg's for all!

Acknowledgements

This package was inspired by blobmaker.app.

License

MIT © artt