config redirect

This commit is contained in:
Nuno Coração
2023-01-29 22:30:24 +00:00
parent 17557c7d73
commit 5fb4bd8083
9905 changed files with 1258996 additions and 36355 deletions
+3
View File
@@ -0,0 +1,3 @@
import type { CHANNELS, Channels } from '../types';
declare const adjust: (color: string | Channels, channels: Partial<CHANNELS>) => string;
export default adjust;
+16
View File
@@ -0,0 +1,16 @@
/* IMPORT */
import Color from '../color/index.js';
import change from './change.js';
/* MAIN */
const adjust = (color, channels) => {
const ch = Color.parse(color);
const changes = {};
for (const c in channels) {
if (!channels[c])
continue;
changes[c] = ch[c] + channels[c];
}
return change(color, changes);
};
/* EXPORT */
export default adjust;
+3
View File
@@ -0,0 +1,3 @@
import type { CHANNEL, Channels } from '../types';
declare const adjustChannel: (color: string | Channels, channel: CHANNEL, amount: number) => string;
export default adjustChannel;
+14
View File
@@ -0,0 +1,14 @@
/* IMPORT */
import _ from '../utils/index.js';
import Color from '../color/index.js';
/* MAIN */
const adjustChannel = (color, channel, amount) => {
const channels = Color.parse(color);
const amountCurrent = channels[channel];
const amountNext = _.channel.clamp[channel](amountCurrent + amount);
if (amountCurrent !== amountNext)
channels[channel] = amountNext;
return Color.stringify(channels);
};
/* EXPORT */
export default adjustChannel;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const alpha: (color: string | Channels) => number;
export default alpha;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import channel from './channel.js';
/* MAIN */
const alpha = (color) => {
return channel(color, 'a');
};
/* EXPORT */
export default alpha;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const blue: (color: string | Channels) => number;
export default blue;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import channel from './channel.js';
/* MAIN */
const blue = (color) => {
return channel(color, 'b');
};
/* EXPORT */
export default blue;
+3
View File
@@ -0,0 +1,3 @@
import type { CHANNELS, Channels } from '../types';
declare const change: (color: string | Channels, channels: Partial<CHANNELS>) => string;
export default change;
+13
View File
@@ -0,0 +1,13 @@
/* IMPORT */
import _ from '../utils/index.js';
import Color from '../color/index.js';
/* MAIN */
const change = (color, channels) => {
const ch = Color.parse(color);
for (const c in channels) {
ch[c] = _.channel.clamp[c](channels[c]);
}
return Color.stringify(ch);
};
/* EXPORT */
export default change;
+3
View File
@@ -0,0 +1,3 @@
import type { CHANNEL, Channels } from '../types';
declare const channel: (color: string | Channels, channel: CHANNEL) => number;
export default channel;
+9
View File
@@ -0,0 +1,9 @@
/* IMPORT */
import _ from '../utils/index.js';
import Color from '../color/index.js';
/* MAIN */
const channel = (color, channel) => {
return _.lang.round(Color.parse(color)[channel]);
};
/* EXPORT */
export default channel;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const complement: (color: string | Channels) => string;
export default complement;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import adjustChannel from './adjust_channel.js';
/* MAIN */
const complement = (color) => {
return adjustChannel(color, 'h', 180);
};
/* EXPORT */
export default complement;
+2
View File
@@ -0,0 +1,2 @@
declare const contrast: (color1: string, color2: string) => number;
export default contrast;
+14
View File
@@ -0,0 +1,14 @@
/* IMPORT */
import _ from '../utils/index.js';
import luminance from './luminance.js';
/* MAIN */
const contrast = (color1, color2) => {
const luminance1 = luminance(color1);
const luminance2 = luminance(color2);
const max = Math.max(luminance1, luminance2);
const min = Math.min(luminance1, luminance2);
const ratio = (max + Number.EPSILON) / (min + Number.EPSILON);
return _.lang.round(_.lang.clamp(ratio, 1, 10));
};
/* EXPORT */
export default contrast;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const darken: (color: string | Channels, amount: number) => string;
export default darken;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import adjustChannel from './adjust_channel.js';
/* MAIN */
const darken = (color, amount) => {
return adjustChannel(color, 'l', -amount);
};
/* EXPORT */
export default darken;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const desaturate: (color: string | Channels, amount: number) => string;
export default desaturate;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import adjustChannel from './adjust_channel.js';
/* MAIN */
const desaturate = (color, amount) => {
return adjustChannel(color, 's', -amount);
};
/* EXPORT */
export default desaturate;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const grayscale: (color: string | Channels) => string;
export default grayscale;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import change from './change.js';
/* MAIN */
const grayscale = (color) => {
return change(color, { s: 0 });
};
/* EXPORT */
export default grayscale;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const green: (color: string | Channels) => number;
export default green;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import channel from './channel.js';
/* MAIN */
const green = (color) => {
return channel(color, 'g');
};
/* EXPORT */
export default green;
+2
View File
@@ -0,0 +1,2 @@
declare const hsla: (h: number, s: number, l: number, a?: number) => string;
export default hsla;
+16
View File
@@ -0,0 +1,16 @@
/* IMPORT */
import _ from '../utils/index.js';
import ChannelsReusable from '../channels/reusable.js';
import Color from '../color/index.js';
/* MAIN */
const hsla = (h, s, l, a = 1) => {
const channels = ChannelsReusable.set({
h: _.channel.clamp.h(h),
s: _.channel.clamp.s(s),
l: _.channel.clamp.l(l),
a: _.channel.clamp.a(a)
});
return Color.stringify(channels);
};
/* EXPORT */
export default hsla;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const hue: (color: string | Channels) => number;
export default hue;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import channel from './channel.js';
/* MAIN */
const hue = (color) => {
return channel(color, 'h');
};
/* EXPORT */
export default hue;
+39
View File
@@ -0,0 +1,39 @@
import hex from './rgba';
import rgb from './rgba';
import rgba from './rgba';
import hsl from './hsla';
import hsla from './hsla';
import toKeyword from './to_keyword';
import toHex from './to_hex';
import toRgba from './to_rgba';
import toHsla from './to_hsla';
import channel from './channel';
import red from './red';
import green from './green';
import blue from './blue';
import hue from './hue';
import saturation from './saturation';
import lightness from './lightness';
import alpha from './alpha';
import opacity from './alpha';
import contrast from './contrast';
import luminance from './luminance';
import isDark from './is_dark';
import isLight from './is_light';
import isValid from './is_valid';
import saturate from './saturate';
import desaturate from './desaturate';
import lighten from './lighten';
import darken from './darken';
import opacify from './opacify';
import fadeIn from './opacify';
import transparentize from './transparentize';
import fadeOut from './transparentize';
import complement from './complement';
import grayscale from './grayscale';
import adjust from './adjust';
import change from './change';
import invert from './invert';
import mix from './mix';
import scale from './scale';
export { hex, rgb, rgba, hsl, hsla, toKeyword, toHex, toRgba, toHsla, channel, red, green, blue, hue, saturation, lightness, alpha, opacity, contrast, luminance, isDark, isLight, isValid, saturate, desaturate, lighten, darken, opacify, fadeIn, transparentize, fadeOut, complement, grayscale, adjust, change, invert, mix, scale };
+53
View File
@@ -0,0 +1,53 @@
/* IMPORT */
import hex from './rgba.js'; // Alias
import rgb from './rgba.js'; // Alias
import rgba from './rgba.js';
import hsl from './hsla.js'; // Alias
import hsla from './hsla.js';
import toKeyword from './to_keyword.js';
import toHex from './to_hex.js';
import toRgba from './to_rgba.js';
import toHsla from './to_hsla.js';
import channel from './channel.js';
import red from './red.js';
import green from './green.js';
import blue from './blue.js';
import hue from './hue.js';
import saturation from './saturation.js';
import lightness from './lightness.js';
import alpha from './alpha.js';
import opacity from './alpha.js'; // Alias
import contrast from './contrast.js';
import luminance from './luminance.js';
import isDark from './is_dark.js';
import isLight from './is_light.js';
import isValid from './is_valid.js';
import saturate from './saturate.js';
import desaturate from './desaturate.js';
import lighten from './lighten.js';
import darken from './darken.js';
import opacify from './opacify.js';
import fadeIn from './opacify.js'; // Alias
import transparentize from './transparentize.js';
import fadeOut from './transparentize.js'; // Alias
import complement from './complement.js';
import grayscale from './grayscale.js';
import adjust from './adjust.js';
import change from './change.js';
import invert from './invert.js';
import mix from './mix.js';
import scale from './scale.js';
/* EXPORT */
export {
/* CREATE */
hex, rgb, rgba, hsl, hsla,
/* CONVERT */
toKeyword, toHex, toRgba, toHsla,
/* GET - CHANNEL */
channel, red, green, blue, hue, saturation, lightness, alpha, opacity,
/* GET - MORE */
contrast, luminance, isDark, isLight, isValid,
/* EDIT - CHANNEL */
saturate, desaturate, lighten, darken, opacify, fadeIn, transparentize, fadeOut, complement, grayscale,
/* EDIT - MORE */
adjust, change, invert, mix, scale };
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const invert: (color: string | Channels, weight?: number) => string;
export default invert;
+13
View File
@@ -0,0 +1,13 @@
/* IMPORT */
import Color from '../color/index.js';
import mix from './mix.js';
/* MAIN */
const invert = (color, weight = 100) => {
const inverse = Color.parse(color);
inverse.r = 255 - inverse.r;
inverse.g = 255 - inverse.g;
inverse.b = 255 - inverse.b;
return mix(inverse, color, weight);
};
/* EXPORT */
export default invert;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const isDark: (color: string | Channels) => boolean;
export default isDark;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import isLight from './is_light.js';
/* MAIN */
const isDark = (color) => {
return !isLight(color);
};
/* EXPORT */
export default isDark;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const isLight: (color: string | Channels) => boolean;
export default isLight;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import luminance from './luminance.js';
/* MAIN */
const isLight = (color) => {
return luminance(color) >= .5;
};
/* EXPORT */
export default isLight;
+2
View File
@@ -0,0 +1,2 @@
declare const isValid: (color: string) => boolean;
export default isValid;
+14
View File
@@ -0,0 +1,14 @@
/* IMPORT */
import Color from '../color/index.js';
/* MAIN */
const isValid = (color) => {
try {
Color.parse(color);
return true;
}
catch {
return false;
}
};
/* EXPORT */
export default isValid;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const lighten: (color: string | Channels, amount: number) => string;
export default lighten;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import adjustChannel from './adjust_channel.js';
/* MAIN */
const lighten = (color, amount) => {
return adjustChannel(color, 'l', amount);
};
/* EXPORT */
export default lighten;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const lightness: (color: string | Channels) => number;
export default lightness;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import channel from './channel.js';
/* MAIN */
const lightness = (color) => {
return channel(color, 'l');
};
/* EXPORT */
export default lightness;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const luminance: (color: string | Channels) => number;
export default luminance;
+12
View File
@@ -0,0 +1,12 @@
/* IMPORT */
import _ from '../utils/index.js';
import Color from '../color/index.js';
/* MAIN */
//SOURCE: https://planetcalc.com/7779
const luminance = (color) => {
const { r, g, b } = Color.parse(color);
const luminance = .2126 * _.channel.toLinear(r) + .7152 * _.channel.toLinear(g) + .0722 * _.channel.toLinear(b);
return _.lang.round(luminance);
};
/* EXPORT */
export default luminance;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const mix: (color1: string | Channels, color2: string | Channels, weight?: number) => string;
export default mix;
+22
View File
@@ -0,0 +1,22 @@
/* IMPORT */
import Color from '../color/index.js';
import rgba from './rgba.js';
/* MAIN */
//SOURCE: https://github.com/sass/dart-sass/blob/7457d2e9e7e623d9844ffd037a070cf32d39c348/lib/src/functions/color.dart#L718-L756
const mix = (color1, color2, weight = 50) => {
const { r: r1, g: g1, b: b1, a: a1 } = Color.parse(color1);
const { r: r2, g: g2, b: b2, a: a2 } = Color.parse(color2);
const weightScale = weight / 100;
const weightNormalized = (weightScale * 2) - 1;
const alphaDelta = a1 - a2;
const weight1combined = ((weightNormalized * alphaDelta) === -1) ? weightNormalized : (weightNormalized + alphaDelta) / (1 + weightNormalized * alphaDelta);
const weight1 = (weight1combined + 1) / 2;
const weight2 = 1 - weight1;
const r = (r1 * weight1) + (r2 * weight2);
const g = (g1 * weight1) + (g2 * weight2);
const b = (b1 * weight1) + (b2 * weight2);
const a = (a1 * weightScale) + (a2 * (1 - weightScale));
return rgba(r, g, b, a);
};
/* EXPORT */
export default mix;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const opacify: (color: string | Channels, amount: number) => string;
export default opacify;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import adjustChannel from './adjust_channel.js';
/* MAIN */
const opacify = (color, amount) => {
return adjustChannel(color, 'a', amount);
};
/* EXPORT */
export default opacify;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const red: (color: string | Channels) => number;
export default red;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import channel from './channel.js';
/* MAIN */
const red = (color) => {
return channel(color, 'r');
};
/* EXPORT */
export default red;
+7
View File
@@ -0,0 +1,7 @@
import type { Channels } from '../types';
declare type IRgba = {
(color: string | Channels, opacity: number): string;
(r: number, g: number, b: number, a?: number): string;
};
declare const rgba: IRgba;
export default rgba;
+19
View File
@@ -0,0 +1,19 @@
/* IMPORT */
import _ from '../utils/index.js';
import ChannelsReusable from '../channels/reusable.js';
import Color from '../color/index.js';
import change from './change.js';
/* MAIN */
const rgba = (r, g, b = 0, a = 1) => {
if (typeof r !== 'number')
return change(r, { a: g });
const channels = ChannelsReusable.set({
r: _.channel.clamp.r(r),
g: _.channel.clamp.g(g),
b: _.channel.clamp.b(b),
a: _.channel.clamp.a(a)
});
return Color.stringify(channels);
};
/* EXPORT */
export default rgba;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const saturate: (color: string | Channels, amount: number) => string;
export default saturate;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import adjustChannel from './adjust_channel.js';
/* MAIN */
const saturate = (color, amount) => {
return adjustChannel(color, 's', amount);
};
/* EXPORT */
export default saturate;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const saturation: (color: string | Channels) => number;
export default saturation;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import channel from './channel.js';
/* MAIN */
const saturation = (color) => {
return channel(color, 's');
};
/* EXPORT */
export default saturation;
+3
View File
@@ -0,0 +1,3 @@
import type { CHANNELS, Channels } from '../types';
declare const scale: (color: string | Channels, channels: Partial<CHANNELS>) => string;
export default scale;
+16
View File
@@ -0,0 +1,16 @@
/* IMPORT */
import _ from '../utils/index.js';
import Color from '../color/index.js';
import adjust from './adjust.js';
/* MAIN */
const scale = (color, channels) => {
const ch = Color.parse(color);
const adjustments = {};
const delta = (amount, weight, max) => weight > 0 ? (max - amount) * weight / 100 : amount * weight / 100;
for (const c in channels) {
adjustments[c] = delta(ch[c], channels[c], _.channel.max[c]);
}
return adjust(color, adjustments);
};
/* EXPORT */
export default scale;
+2
View File
@@ -0,0 +1,2 @@
declare const toHex: (color: string) => string;
export default toHex;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import Color from '../color/index.js';
/* MAIN */
const toHex = (color) => {
return Color.format.hex.stringify(Color.parse(color));
};
/* EXPORT */
export default toHex;
+2
View File
@@ -0,0 +1,2 @@
declare const toHsla: (color: string) => string;
export default toHsla;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import Color from '../color/index.js';
/* MAIN */
const toHsla = (color) => {
return Color.format.hsla.stringify(Color.parse(color));
};
/* EXPORT */
export default toHsla;
+2
View File
@@ -0,0 +1,2 @@
declare const toKeyword: (color: string) => string | undefined;
export default toKeyword;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import Color from '../color/index.js';
/* MAIN */
const toKeyword = (color) => {
return Color.format.keyword.stringify(Color.parse(color));
};
/* EXPORT */
export default toKeyword;
+2
View File
@@ -0,0 +1,2 @@
declare const toRgba: (color: string) => string;
export default toRgba;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import Color from '../color/index.js';
/* MAIN */
const toRgba = (color) => {
return Color.format.rgba.stringify(Color.parse(color));
};
/* EXPORT */
export default toRgba;
+3
View File
@@ -0,0 +1,3 @@
import type { Channels } from '../types';
declare const transparentize: (color: string | Channels, amount: number) => string;
export default transparentize;
+8
View File
@@ -0,0 +1,8 @@
/* IMPORT */
import adjustChannel from './adjust_channel.js';
/* MAIN */
const transparentize = (color, amount) => {
return adjustChannel(color, 'a', -amount);
};
/* EXPORT */
export default transparentize;