Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vibrant/color

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vibrant/color - npm Package Compare versions

Comparing version 3.2.0-alpha.1 to 3.2.1-alpha.1

19

lib/converter.d.ts

@@ -9,4 +9,23 @@ import { Vec3 } from './';

};
/**
* Converts hex string to RGB
* @param hex - The hex value you with to get the RGB value of
* @returns an array in the order of `red, green, blue` numerical values
*/
export declare function hexToRgb(hex: string): Vec3;
/**
* Given values for an RGB color convert to and return a valid HEX string
* @param r - Red value in RGB
* @param g - Green value in RGB
* @param b - Blue value in RGB
* @returns a valid hex string with pre-pending pound sign
*/
export declare function rgbToHex(r: number, g: number, b: number): string;
/**
* Given values for an RGB color convert to and return a valid HSL value
* @param r - Red value in RGB
* @param g - Green value in RGB
* @param b - Blue value in RGB
* @returns an array in the order of `hue, saturation, light` numerical values
*/
export declare function rgbToHsl(r: number, g: number, b: number): Vec3;

@@ -13,0 +32,0 @@ export declare function hslToRgb(h: number, s: number, l: number): Vec3;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getColorDiffStatus = exports.hexDiff = exports.rgbDiff = exports.deltaE94 = exports.rgbToCIELab = exports.xyzToCIELab = exports.rgbToXyz = exports.hslToRgb = exports.rgbToHsl = exports.rgbToHex = exports.hexToRgb = exports.DELTAE94_DIFF_STATUS = void 0;
exports.DELTAE94_DIFF_STATUS = {

@@ -10,2 +11,7 @@ NA: 0,

};
/**
* Converts hex string to RGB
* @param hex - The hex value you with to get the RGB value of
* @returns an array in the order of `red, green, blue` numerical values
*/
function hexToRgb(hex) {

@@ -18,2 +24,9 @@ var m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);

exports.hexToRgb = hexToRgb;
/**
* Given values for an RGB color convert to and return a valid HEX string
* @param r - Red value in RGB
* @param g - Green value in RGB
* @param b - Blue value in RGB
* @returns a valid hex string with pre-pending pound sign
*/
function rgbToHex(r, g, b) {

@@ -23,2 +36,9 @@ return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1, 7);

exports.rgbToHex = rgbToHex;
/**
* Given values for an RGB color convert to and return a valid HSL value
* @param r - Red value in RGB
* @param g - Green value in RGB
* @param b - Blue value in RGB
* @returns an array in the order of `hue, saturation, light` numerical values
*/
function rgbToHsl(r, g, b) {

@@ -25,0 +45,0 @@ r /= 255;

66

lib/index.d.ts
export interface Filter {
(red: number, green: number, blue: number, alpha: number): boolean;
}
/**
* 3d floating pointer vector
*/
export declare type Vec3 = [number, number, number];
/**
* The layout for a node-vibrant Palette. Allows you to keep track of
*/
export interface Palette {

@@ -16,2 +22,6 @@ Vibrant: Swatch | null;

static applyFilters(colors: Swatch[], filters: Filter[]): Swatch[];
/**
* Make a value copy of a swatch based on a previous one. Returns a new Swatch instance
* @param {Swatch} swatch
*/
static clone(swatch: Swatch): Swatch;

@@ -23,16 +33,52 @@ private _hsl;

private _hex;
readonly r: number;
readonly g: number;
readonly b: number;
readonly rgb: Vec3;
readonly hsl: Vec3;
readonly hex: string;
readonly population: number;
/**
* The red value in the RGB value
*/
get r(): number;
/**
* The green value in the RGB value
*/
get g(): number;
/**
* The blue value in the RGB value
*/
get b(): number;
/**
* The color value as a rgb value
*/
get rgb(): Vec3;
/**
* The color value as a hsl value
*/
get hsl(): Vec3;
/**
* The color value as a hex string
*/
get hex(): string;
get population(): number;
/**
* Get the JSON object for the swatch
*/
toJSON(): {
rgb: [number, number, number];
rgb: Vec3;
population: number;
};
/**
* Get the color value as a rgb value
* @deprecated Use property instead
*/
getRgb(): Vec3;
/**
* Get the color value as a hsl value
* @deprecated Use property instead
*/
getHsl(): Vec3;
/**
* @deprecated Use property instead
*/
getPopulation(): number;
/**
* Get the color value as a hex string
* @deprecated Use property instead
*/
getHex(): string;

@@ -42,4 +88,4 @@ private getYiq;

private _bodyTextColor;
readonly titleTextColor: string;
readonly bodyTextColor: string;
get titleTextColor(): string;
get bodyTextColor(): string;
getTitleTextColor(): string;

@@ -46,0 +92,0 @@ getBodyTextColor(): string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Swatch = void 0;
var converter_1 = require("./converter");

@@ -21,2 +22,6 @@ var Swatch = /** @class */ (function () {

};
/**
* Make a value copy of a swatch based on a previous one. Returns a new Swatch instance
* @param {Swatch} swatch
*/
Swatch.clone = function (swatch) {

@@ -26,30 +31,45 @@ return new Swatch(swatch._rgb, swatch._population);

Object.defineProperty(Swatch.prototype, "r", {
/**
* The red value in the RGB value
*/
get: function () {
return this._rgb[0];
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Swatch.prototype, "g", {
/**
* The green value in the RGB value
*/
get: function () {
return this._rgb[1];
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Swatch.prototype, "b", {
/**
* The blue value in the RGB value
*/
get: function () {
return this._rgb[2];
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Swatch.prototype, "rgb", {
/**
* The color value as a rgb value
*/
get: function () {
return this._rgb;
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Swatch.prototype, "hsl", {
/**
* The color value as a hsl value
*/
get: function () {

@@ -62,6 +82,9 @@ if (!this._hsl) {

},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Swatch.prototype, "hex", {
/**
* The color value as a hex string
*/
get: function () {

@@ -74,3 +97,3 @@ if (!this._hex) {

},
enumerable: true,
enumerable: false,
configurable: true

@@ -82,5 +105,8 @@ });

},
enumerable: true,
enumerable: false,
configurable: true
});
/**
* Get the JSON object for the swatch
*/
Swatch.prototype.toJSON = function () {

@@ -92,2 +118,6 @@ return {

};
/**
* Get the color value as a rgb value
* @deprecated Use property instead
*/
// TODO: deprecate internally, use property instead

@@ -97,2 +127,6 @@ Swatch.prototype.getRgb = function () {

};
/**
* Get the color value as a hsl value
* @deprecated Use property instead
*/
// TODO: deprecate internally, use property instead

@@ -102,2 +136,5 @@ Swatch.prototype.getHsl = function () {

};
/**
* @deprecated Use property instead
*/
// TODO: deprecate internally, use property instead

@@ -107,2 +144,6 @@ Swatch.prototype.getPopulation = function () {

};
/**
* Get the color value as a hex string
* @deprecated Use property instead
*/
// TODO: deprecate internally, use property instead

@@ -126,3 +167,3 @@ Swatch.prototype.getHex = function () {

},
enumerable: true,
enumerable: false,
configurable: true

@@ -137,3 +178,3 @@ });

},
enumerable: true,
enumerable: false,
configurable: true

@@ -140,0 +181,0 @@ });

7

package.json
{
"name": "@vibrant/color",
"version": "3.2.0-alpha.1",
"version": "3.2.1-alpha.1",
"description": "Color utilities for vibrant",

@@ -20,7 +20,8 @@ "scripts": {

"devDependencies": {
"typescript": "^3.2.2"
"typescript": "^3.7.2"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "e667d4c12e1de66e251d451710b093e9cb4630c2"
}

@@ -11,2 +11,7 @@ import { Vec3 } from './'

/**
* Converts hex string to RGB
* @param hex - The hex value you with to get the RGB value of
* @returns an array in the order of `red, green, blue` numerical values
*/
export function hexToRgb (hex: string): Vec3 {

@@ -20,2 +25,9 @@ let m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)

/**
* Given values for an RGB color convert to and return a valid HEX string
* @param r - Red value in RGB
* @param g - Green value in RGB
* @param b - Blue value in RGB
* @returns a valid hex string with pre-pending pound sign
*/
export function rgbToHex (r: number, g: number, b: number): string {

@@ -25,2 +37,9 @@ return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1, 7)

/**
* Given values for an RGB color convert to and return a valid HSL value
* @param r - Red value in RGB
* @param g - Green value in RGB
* @param b - Blue value in RGB
* @returns an array in the order of `hue, saturation, light` numerical values
*/
export function rgbToHsl (r: number, g: number, b: number): Vec3 {

@@ -27,0 +46,0 @@ r /= 255

@@ -7,4 +7,10 @@ import { rgbToHsl, rgbToHex } from './converter'

/**
* 3d floating pointer vector
*/
export type Vec3 = [number, number, number]
/**
* The layout for a node-vibrant Palette. Allows you to keep track of
*/
export interface Palette {

@@ -17,2 +23,3 @@ Vibrant: Swatch | null

LightMuted: Swatch | null
// ?
[name: string]: Swatch | null

@@ -32,2 +39,7 @@ }

}
/**
* Make a value copy of a swatch based on a previous one. Returns a new Swatch instance
* @param {Swatch} swatch
*/
static clone (swatch: Swatch) {

@@ -41,14 +53,30 @@ return new Swatch(swatch._rgb, swatch._population)

private _hex: string
/**
* The red value in the RGB value
*/
get r (): number {
return this._rgb[0]
}
/**
* The green value in the RGB value
*/
get g (): number {
return this._rgb[1]
}
/**
* The blue value in the RGB value
*/
get b (): number {
return this._rgb[2]
}
/**
* The color value as a rgb value
*/
get rgb (): Vec3 {
return this._rgb
}
/**
* The color value as a hsl value
*/
get hsl (): Vec3 {

@@ -61,3 +89,7 @@ if (!this._hsl) {

}
get hex () {
/**
* The color value as a hex string
*/
get hex (): string {
if (!this._hex) {

@@ -73,3 +105,6 @@ let [r, g, b] = this._rgb

toJSON () {
/**
* Get the JSON object for the swatch
*/
toJSON (): {rgb: Vec3, population: number} {
return {

@@ -81,2 +116,6 @@ rgb: this.rgb,

/**
* Get the color value as a rgb value
* @deprecated Use property instead
*/
// TODO: deprecate internally, use property instead

@@ -86,2 +125,6 @@ getRgb (): Vec3 {

}
/**
* Get the color value as a hsl value
* @deprecated Use property instead
*/
// TODO: deprecate internally, use property instead

@@ -91,2 +134,5 @@ getHsl (): Vec3 {

}
/**
* @deprecated Use property instead
*/
// TODO: deprecate internally, use property instead

@@ -96,2 +142,6 @@ getPopulation (): number {

}
/**
* Get the color value as a hex string
* @deprecated Use property instead
*/
// TODO: deprecate internally, use property instead

@@ -98,0 +148,0 @@ getHex (): string {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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