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

mad-colorlib

v1.0.1

Published

Some utilities to deal with colors.

Downloads

1

Readme

Initialization: const colorlib = ColorLib()

colorlib.get_dominant(image, palette_size=1, use_limits=false)

This gets the dominant color or colors of an image. Palette size is the number of colors to return. If use_limits is true it will ignore colors when r, g, and b are below 10 or above 245.

colorlib.get_lighter_or_darker(rgb, amount=0.2)

This returns a darker color if the color is considered light, or a lighter color if the color is considered dark. rgb is an array like [0, 20, 5]. amount specifies how much darker or lighter it gets.

colorlib.is_light(rgb)

Checks if a color is considered light. Receives an rgb array.

colorlib.is_dark(rgb)

Checks if a color is considered dark. Receives an rgb array.

colorlib.get_proper_font(rgb)

Used to give a proper font color to a background color. If color is light it returns #000000. If color is dark it returns #ffffff. Although it's advised to use get_lighter_or_darker to achieve more natural contrasts.

colorlib.array_to_rgb(array)

Transforms an rgb array like [x, y, z] into rgb(x, y, z). An array with multiple array arguments can be passed.

colorlib.rgb_to_array(rgb)

Transforms rgb(x, y, z) to [x, y, z]. An array with multiple rgb arguments can be passed.

colorlib.rgb_to_rgba(rgb, alpha)

Replaces rgb(x, y, z) to rgba(x, y, z, alpha).

colorlib.rgba_to_rgb(rgb, alpha)

Replaces rgba(x, y, z, alpha) to rgb(x, y, z).

colorlib.rgb_to_hex(rgb, hash=true)

This turns an array to a hex string. If an rgb string is given it will convert it to an array automatically. For instance [1,2,3] or "rgb(1, 2, 3)" will turn to "#010203", If hash is false it won't add the # to the string.

colorlib.hex_to_rgb(hex)

This turns a hex string to an rgb array. For instance "#010203" or "010203" will return [1,2,3],

colorlib.check_array(array)

Checks if an rgb array is composed of valid values. A valid value is between 0 and 255. If a value is not in that range it is fixed. This returns a valid array, not true or false.

colorlib.check_rgb(rgb)

This checks if rgb is an array. If not, an array is created and returned. rgb(0, 1, 2) would return [0, 1, 2].