![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A modern JavaScript library delivering fast and modular color utils. (eg. color convertor, css color validator and parser etc.)
A modern JavaScript library delivering fast and modular color utils.
Collit is a modern JavaScript library delivering fast and modular color utils.
Our mission is to create a complete, fast, modular and well-documented library for any kind of color operations (eg. parsers, converters, transformers, manipulation etc.).
Library can be used both in Node.js and directly in Browser. It is well-documented and completely covered with test specs (excluding webpack bundling definitions and expressions).
If you want to add some features or to suggest any idea, feel free — contributions are always welcome.
There are several modules available in Collit so far:
To use Collit with NPM simply call:
npm install --save collit
To use Collit directly in browser simply download this repository and copy dist/collit.js into your project. Next, include it on your .html page:
<script src="path/to/your/js/collit.js"></script>
You are able to use Collit as the importable npm package or directly in browser.
import { Parser } from "collit";
var color = Parser.parseRgb("rgb(128,128,128");
// color => { hex: "#808080", rgb: {r:128, g:128, b:128}, hsl: {h:0, s:0, l:0.5}}
<script>
var Parser = Collit.Parser;
var color = Parser.parseRgb("rgb(128,128,128");
// color => { hex: "#808080", rgb: {r:128, g:128, b:128}, hsl: {h:0, s:0, l:0.5}}
</script>
Convert one specific color format into another. (Hex, RGB, HSL).
Converts an HEX color value to RGB.
import Converter from "collit"; // or var Converter = Collit.Converter if using in browser
var rgb = Converter.hexToRgb("#333"); // rgb => {r:51, g:51, b: 51};
Converts an HEX color value to HSL.
Converting hex to hsl is done using a additional converting to RGB. HEX -> RGB -> HSL.
import Converter from "collit"; // or var Converter = Collit.Converter if using in browser
var hsl = Converter.hexToHsl("#333"); // hsl => {h: 0, s: 0, l: 0.2};
Converts an RGB color value to HEX.
import Converter from "collit"; // or var Converter = Collit.Converter if using in browser
var hex = Converter.rgbToHex({r: 51, g: 51, b: 51}); // hex => "#333";
Converts an RGB color value to HSL.
var hsl = Converter.rgbToHsl({r: 11, g: 11, b: 11}); // hsl => {h: 0, s: 0, l: 0.04};
Converts an HSL color value to Hex.
Converting hsl to hex is done using a additional converting to RGB. HSL -> RGB -> HEX.
import Converter from "collit"; // or var Converter = Collit.Converter if using in browser
var hex = Converter.hslToHex({h: 0, s: 0.5, l: 0.3}); // hex => "#732626;
Converts an HSL color value to RGB.
import Converter from "collit"; // or var Converter = Collit.Converter if using in browser
var rgb = Converter.hslToRgb({h: 300, s: 0.5, l: 0.5}); // rgb => {r: 191, g: 64, b: 191};
Validator Helper that allows you to check if color is defined as a correct hex, rgb, rgba, hsl, hsla CSS string or gradient defined correctly.
Check if target name is a valid CSS1, CSS2.1, CSS3 color name
import Validator from "collit"; // or var Validator = Collit.Validator if using in browser
var isColor = Validator.isColorName("black"); // true
var isNotColor = Validator.isColorName("avadakedavra"); // false
Check if target string is a valid hex color
import Validator from "collit"; // or var Validator = Collit.Validator if using in browser
var isHex = Validator.isHex("#333"); // true
var isNotHex = Validator.isHex("#rgb"); // false
Check if target string is a valid css rgb color definition
import Validator from "collit"; // or var Validator = Collit.Validator if using in browser
var isRgb = Validator.isRgb("rgb( 0, 0, 0 )") // true
var isNotRgb = Validator.isRgb("hsl( 0, 0, 100% )") // false
Check if target string is a valid css HSL color definition
import Validator from "collit"; // or var Validator = Collit.Validator if using in browser
var isHsl = Validator.isHsl("hsl(0,0%,0%)") // true
var isNotHsl = Validator.isHsl("hsl( 0, 5, 100% )") // false
Check if target string is a valid css rgba color definition
import Validator from "collit"; // or var Validator = Collit.Validator if using in browser
var isRgba = Validator.isRgba("rgba(255,255,255,.5)") // true
var isNotRgba = Validator.isRgba("hsla(255,100%,100%,.5)") // false
Check if target string is a valid css HSLa color definition
import Validator from "collit"; // or var Validator = Collit.Validator if using in browser
var isHsla = Validator.isHsla("hsla(0,0%,0%, .5)") // true
var isNotHsla = Validator.isHsla("hsl( 0, 5, 100% )") // false
Check if target string is a valid css color definition
import Validator from "collit"; // or var Validator = Collit.Validator if using in browser
var isColor = Validator.isColor("hsla(0,0%,0%, .5)") // true
var isColorToo = Validator.isColor("black") // true
var isNotColor = Validator.isColor("color") // false
Parser Helper allows you to parse a CSS based color definition into the ColorInfo object, which contains a hex, rgb and hsl values of target css value.
Parse a valid CSS1, CSS2.1, CSS3 color name into a set of hex, rgb and hsl values.
import Parser from "collit"; // or var Parser = Collit.Parser if using in browser
var color = Parser.parseColorName("black");
// color => { hex: "#000", rgb: {r:0, g:0, b:0}, hsl: {h:0, s:0, l:0}}
Parse a valid hex color into a set of hex, rgb and hsl values
import Parser from "collit"; // or var Parser = Collit.Parser if using in browser
var color = Parser.parseHex("#000");
// color => { hex: "#000", rgb: {r:0, g:0, b:0}, hsl: {h:0, s:0, l:0}}
Parse a valid css rgb color into a set of hex, rgb and hsl values
import Parser from "collit"; // or var Parser = Collit.Parser if using in browser
var color = Parser.parseRgb("rgb(128,128,128");
// color => { hex: "#808080", rgb: {r:128, g:128, b:128}, hsl: {h:0, s:0, l:0.5}}
Parse a valid css hsl color into a set of hex, rgb and hsl values
import Parser from "collit"; // or var Parser = Collit.Parser if using in browser
var color = Parser.parseHsl("hsl(240,100%,50%");
// color => { hex: "#00f", rgb: {r:0, g:0, b:255}, hsl: {h:240, s:1, l:0.5}}
Parse a valid css rgba color into a set of hex, rgb and hsl values
import Parser from "collit"; // or var Parser = Collit.Parser if using in browser
var color = Parser.parseRgba("rgba(255,0,0,.5)");
// color => { hex: "#f00", rgb: {r:255, g:0, b:0, a: 0.5}, hsl: {h:0, s:1, l: 0.5, a: 0.5} }
Parse a valid css hsla color into a set of hex, rgb and hsl values
import Parser from "collit"; // or var Parser = Collit.Parser if using in browser
var color = Parser.parseRgba("hsla(0,255,0,.5)");
// color => { hex: "#0f0", rgb: {r:0, g:255, b:0, a: 0.5}, hsl: {h:120, s:1, l: 0.5, a: 0.5} }
Parse a valid css color into a set of hex, rgb and hsl values
import Parser from "collit"; // or var Parser = Collit.Parser if using in browser
var color = Parser.parseColor("hsla(0,255,0,.5)");
// color => { hex: "#0f0", rgb: {r:0, g:255, b:0, a: 0.5}, hsl: {h:120, s:1, l: 0.5, a: 0.5} }
var anotherColor = Parser.parseColor("rgba(255,0,0,.5)");
// color => { hex: "#f00", rgb: {r:255, g:0, b:0, a: 0.5}, hsl: {h:0, s:1, l: 0.5, a: 0.5} }
var oneMoreColor = Parser.parseColor("black");
// color => { hex: "#000", rgb: {r:0, g:0, b:0}, hsl: {h:0, s:0, l:0}}
Contributions are always welcome. Before contributing please read the code of conduct & search the issue tracker (your issue may have already been discussed or fixed).
To contribute, follow next steps:
Feature requests should be submitted in the issue tracker, with a description of the expected behavior & use case, where they’ll remain closed until sufficient interest (e.g. 👍 reactions). Before submitting a feature request, please search for similar ones in the closed issues.
The entire logic of modules is and should be based on use of the Color, LinearGradient and RadialGradient data types.
Describes a specific color as a set of hex, rgb and hsl values
{
hex: "#333",
rgb: { r: 51, g: 51, b: 51, a: 1 },
hsl: { h: 0, s: 0 l: 0.1 a: 1 }
}
"A" — inside the rgb and hsl values is optional and can be omitted.
Describes a specific set of linear gradient values.
{
angle: 45,
sideCorner: "top right"
colorStopList: [
{
position: 0, // 0%
color: { rgb: { r: 51, g: 51, b: 51, a: 1 } }
},
{
position: 1, // 100%
color: { hex: "#333" }
}
],
}
Describes a specific set of radial gradient values.
{
position: [.25, .75], // at 25% 75%
shape: "circle",
extent: "closest-side",
colorStopList: [
{
position: 0, // 0%
color: { hsl: { h: 0, s: 0 l: 0.1 a: 1 } }
},
{
position: 1, // 100%
color: { rgb: { r: 51, g: 51, b: 51, a: 1 } }
}
],
}
Released under the MIT License
FAQs
A modern JavaScript library delivering fast and modular color utils. (eg. color convertor, css color validator and parser etc.)
We found that collit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.