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

color-processing-library

v1.2.5

Published

A small library for color processing

Downloads

15

Readme

Soft UI color processing

A small javascript library for color processing.

color-processing-library is available on npm. To install it, type:

npm i color-processing-library

Functionality Import example:

import * as colorProcessing from 'color-processing-library'  

Funcitons toHex(number) - The function converts decimal number to hexadecimal value

Example

toHex(255) // returns 'FF' 
toHex(0) // returns '00'

calculateColor(colorValue, factor) - The function calculates a new color value in percent of the initial color

Example

calculateColor(225, 85) // returns 191
calculateColor(89, 120) // returns 107

getFontColor(red, green, blue) - The function calculates and returns either black or white hexadecimal color code depending on the color input

Examples

let red, green, blue = 240;
getFontColor(red, green, blue) // returns '#000'
let red, green, blue = 30;
getFontColor(red, green, blue) // returns '#FFF'

getFontColorHex(hexColor) - The function calculates and returns either black or white hexadecimal color code depend on the color input | input - Hexadecimal color code

Example

getFontColorHex('#F0F0F0') // returns '#000'
getFontColorHex('#303030') // returns '#FFF'

hexToRGB(hexColor) - The function converts hexadecimal color code to rgb

Example

hexToRGB('#ED2939') // returns { Red:237, Green:41, Blue:57 }
hexToRGB() // returns "Invalid Hex code value"

isHexColorValid(hexColor) - The function validates hexadecimal color and returns either true or false

Example

isHexColorValid('#ED2939') // returns true
isHexColorValid('#Helloo') // returns false

getTintsAndShades(red, green, blue, factor, outputMode) - The function returns new color in % of input color as hex or rgb

Example

getTintsAndShades(255, 255, 255, 85, 'rgb') // returns 'rgb(217,217,217)'
getTintsAndShades(255, 255, 255, 85, 'hex') // returns '#D9D9D9'

invertFontColor(hexColor) - Function returns opposite color

❗️Note This function currently works only with black and white hex values

Example

getTintsAndShades("#000") // returns '#FFF'

getHarmonyColor(color, mode) - Function returns a harmony color depend on a mode

❗ ️Note This function currently works only in complementary mode

Example

getHarmonyColor("#ED2939", 'complementary') // returns '#12D6C6'