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

@joecooper1/stained-glass-generator

v1.0.2

Published

Creates a randomised stained glass pattern on an HTML canvas

Downloads

5

Readme

Stained-Glass Generator

A package that creates a random stained-glass pattern, based on inputted options, applied on an HTML canvas.


Contents


A few different possibilities:

example images


Installation

$ npm install @joecooper1/stained-glass

Use

First, import it into your file:

import drawStainedGlass from '@joecooper1/stained-glass';

You'll need to create your own HTML canvas. You can do anything you like to it - eg give it a background image - before apllying the stained glass effect. Or you can draw the stained glass, and then draw something else on top of it.

For info on how to use the canvas, try here.

Once your canvas is set up, just call the function using the canvas reference, here called 'ctx'.

You'll also need to input the height and width of the canvas, in that order.

drawStainedGlass(ctx, height, width, [options] -> {})

That's it! But if you want to customise it, check out the options.


Options

The fourth argument to be passed in to the function is the options. It takes the form of an object with various parameters, all of which are optional.

Here they are:

Option | Input | Range | Effect ------------|-------------|-------------|------------ shape | string | 'abstract', 'rectangle', 'circle', 'ring' | Determines the shapes that make up the pattern. Defaults to abstract. pieceSize | integer / [integer, integer] | 5 and up | Determines the size of each pane in pixels. Input can be given as a single integer, or as an array containing the width and the height. Defaults to 25. lineWidth | integer | 0 - 10 | Determines the thickness of the lines seperating each pane. Defaults to 1. Tip - try settings it to 0 when the size of the panes is small. lineColor | string | any valid color | Sets the color for the lines to be drawn in. Defaults to black. deviation | integer | 0 and up | Determines how irregular the shapes are. Only applies to the abstract pattern. Tip - Putting it higher than the size of the pieces will produce probably bad effects. colorScheme | string | 'rgb', 'hsl' | Determines what type of color values will be used to make the colors. The difference is slight, but in general 'rgb' produces a subtler pattern than 'hsl', which can be quite brash. Defaults to rgb. colorConsistency | integer | 0 - 200 | Determines how varied the colors will be. 0 means perfectly uniform, 200 means completely random. Defaults to 30. scatter | integer | 0 - 10 | Scatters the light across the panes, sort of. 10 scatters light a lot, 0 not at all. Only works for abstract pattern on hsl settings for now, because it looks gross on everything else. Defaults to 5. transparency | number | 0 - 1 | Determines the transparency of the glass. Defaults to 1, or to 0.5 if the pattern is rings. angle | integer | 0 - 10 | Determines the angle of horizontal lines. Only works for the rectangle pattern. Work in progress - for now it does not work 100%.


License

License


Me

Here's the code on github: https://github.com/joecooper1/stained-glass-generator

Here's me: https://joecooper1.github.io/pf/