New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mad-colorlib

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mad-colorlib

Some utilities to deal with colors.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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].

Keywords

FAQs

Package last updated on 02 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc