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-manipulator

v1.0.1

Published

Color manipulator class and utilities

Downloads

5

Readme

color-manipulator

Color API to operate mathematically with numbers in RGB and HEX formats. For both, browser and Node.js.

Online user interface

Visit the online user interface here:

Installation

npm install --save color-manipulator

Usage

Use the classic import or require statement for Node.js

In the browser, you can use the src/color-manipulator.js as standalone <script> import, or the API or browserify, webpack or this kind of bundlers.

API reference

You can visit the REFERENCE.md file to find all the methods of the API.

The color-calculator-parser

The color-calculator-parser is the parser for making color mathematical operations. These operations are allowed (each line is valid, separatedly only):

#000000 + #00FF00 + #0000FF
#000000 + 1 + 3 + 4
#00FF00 - #00FF00
#FFFFFF - 1 - 3 - 4
#010101 * 5 * 10
#202020 / 2 / 2
( #000000 + 10 ) - ( #000000 + 10 )

If you get the idea, this is enough. You can multiply colors by colors, and divide, but if you don't use it as a way of matrix, the numbers get easily out of bounds. In additions and substractions, it has more sense. But everything is allowed.

Examples

The test verses as follows:

const { Color } = require(__dirname + "/../src/color-manipulator.js");

const color_1 = Color.create("rgb(255,255,255)");
const color_2 = Color.create("#101010");
const color_3 = Color.create("#FFF");

const color_in_rgb = color_1.toRGB();
const color_in_hex = color_1.toHexadecimal();

console.log("color_1:", color_1);
console.log("color_2:", color_2);
console.log("color_3:", color_3);
console.log("color_in_rgb:", color_in_rgb);
console.log("color_in_hex:", color_in_hex);

console.log("color_1.substractColor:", color_1.cloned().substractColor(Color.create("rgb(127,127,127)")));
console.log("color_1.substractFromRed:", color_1.cloned().substractFromRed(Color.hexToNumber("FF")));
console.log("color_1.substractFromGreen:", color_1.cloned().substractFromGreen(Color.hexToNumber("FF")));
console.log("color_1.substractFromBlue:", color_1.cloned().substractFromBlue(Color.hexToNumber(Color.numberToHex("200"))));

console.log("color_2.addColor:", color_2.cloned().addColor(Color.create("rgb(127,127,127)")));
console.log("color_2.addToRed:", color_2.cloned().addToRed(Color.hexToNumber("FF")));
console.log("color_2.addToGreen:", color_2.cloned().addToGreen(Color.hexToNumber("FF")));
console.log("color_2.addToBlue:", color_2.cloned().addToBlue(Color.hexToNumber(Color.numberToHex("200"))));

console.log("color_2.multiplyAllBy:", color_2.cloned().multiplyAllBy(2));
console.log("color_2.multiplyRedBy:", color_2.cloned().multiplyRedBy(Color.hexToNumber("0A")));
console.log("color_2.multiplyGreenBy:", color_2.cloned().multiplyGreenBy(Color.hexToNumber("0A")));
console.log("color_3.multiplyBlueBy:", color_2.cloned().multiplyBlueBy(Color.hexToNumber(Color.numberToHex("10"))));

console.log("color_2.divideAllBy:", color_3.cloned().divideAllBy(2).rounded());
console.log("color_3.divideRedBy:", color_3.cloned().divideRedBy(Color.hexToNumber("0A")).rounded());
console.log("color_3.divideGreenBy:", color_3.cloned().divideGreenBy(Color.hexToNumber("0A")).rounded());
console.log("color_3.divideBlueBy:", color_3.cloned().divideBlueBy(Color.hexToNumber(Color.numberToHex("10"))).rounded());

Maybe it is poor, but you can play with the online UI playground.