This commit is contained in:
nik
2025-10-03 22:27:28 +03:00
parent 829fad0e17
commit 871cf7e792
16520 changed files with 2967597 additions and 3 deletions

27
node_modules/khroma/dist/channels/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import Type from './type';
import type { RGBA, HSLA, CHANNELS } from '../types';
declare class Channels {
color?: string;
changed: boolean;
data: CHANNELS;
type: Type;
constructor(data: RGBA | HSLA | CHANNELS, color?: string);
set(data: RGBA | HSLA | CHANNELS, color?: string): this;
_ensureHSL(): void;
_ensureRGB(): void;
get r(): number;
get g(): number;
get b(): number;
get h(): number;
get s(): number;
get l(): number;
get a(): number;
set r(r: number);
set g(g: number);
set b(b: number);
set h(h: number);
set s(s: number);
set l(l: number);
set a(a: number);
}
export default Channels;

132
node_modules/khroma/dist/channels/index.js generated vendored Normal file
View File

@@ -0,0 +1,132 @@
/* IMPORT */
import _ from '../utils/index.js';
import Type from './type.js';
import { TYPE } from '../constants.js';
/* MAIN */
class Channels {
/* CONSTRUCTOR */
constructor(data, color) {
this.color = color;
this.changed = false;
this.data = data; //TSC
this.type = new Type();
}
/* API */
set(data, color) {
this.color = color;
this.changed = false;
this.data = data; //TSC
this.type.type = TYPE.ALL;
return this;
}
/* HELPERS */
_ensureHSL() {
const data = this.data;
const { h, s, l } = data;
if (h === undefined)
data.h = _.channel.rgb2hsl(data, 'h');
if (s === undefined)
data.s = _.channel.rgb2hsl(data, 's');
if (l === undefined)
data.l = _.channel.rgb2hsl(data, 'l');
}
_ensureRGB() {
const data = this.data;
const { r, g, b } = data;
if (r === undefined)
data.r = _.channel.hsl2rgb(data, 'r');
if (g === undefined)
data.g = _.channel.hsl2rgb(data, 'g');
if (b === undefined)
data.b = _.channel.hsl2rgb(data, 'b');
}
/* GETTERS */
get r() {
const data = this.data;
const r = data.r;
if (!this.type.is(TYPE.HSL) && r !== undefined)
return r;
this._ensureHSL();
return _.channel.hsl2rgb(data, 'r');
}
get g() {
const data = this.data;
const g = data.g;
if (!this.type.is(TYPE.HSL) && g !== undefined)
return g;
this._ensureHSL();
return _.channel.hsl2rgb(data, 'g');
}
get b() {
const data = this.data;
const b = data.b;
if (!this.type.is(TYPE.HSL) && b !== undefined)
return b;
this._ensureHSL();
return _.channel.hsl2rgb(data, 'b');
}
get h() {
const data = this.data;
const h = data.h;
if (!this.type.is(TYPE.RGB) && h !== undefined)
return h;
this._ensureRGB();
return _.channel.rgb2hsl(data, 'h');
}
get s() {
const data = this.data;
const s = data.s;
if (!this.type.is(TYPE.RGB) && s !== undefined)
return s;
this._ensureRGB();
return _.channel.rgb2hsl(data, 's');
}
get l() {
const data = this.data;
const l = data.l;
if (!this.type.is(TYPE.RGB) && l !== undefined)
return l;
this._ensureRGB();
return _.channel.rgb2hsl(data, 'l');
}
get a() {
return this.data.a;
}
/* SETTERS */
set r(r) {
this.type.set(TYPE.RGB);
this.changed = true;
this.data.r = r;
}
set g(g) {
this.type.set(TYPE.RGB);
this.changed = true;
this.data.g = g;
}
set b(b) {
this.type.set(TYPE.RGB);
this.changed = true;
this.data.b = b;
}
set h(h) {
this.type.set(TYPE.HSL);
this.changed = true;
this.data.h = h;
}
set s(s) {
this.type.set(TYPE.HSL);
this.changed = true;
this.data.s = s;
}
set l(l) {
this.type.set(TYPE.HSL);
this.changed = true;
this.data.l = l;
}
set a(a) {
this.changed = true;
this.data.a = a;
}
}
/* EXPORT */
export default Channels;

3
node_modules/khroma/dist/channels/reusable.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import Channels from './';
declare const channels: Channels;
export default channels;

6
node_modules/khroma/dist/channels/reusable.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/* IMPORT */
import Channels from './/index.js';
/* MAIN */
const channels = new Channels({ r: 0, g: 0, b: 0, a: 0 }, 'transparent');
/* EXPORT */
export default channels;

8
node_modules/khroma/dist/channels/type.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
declare class Type {
type: number;
get(): number;
set(type: number): void;
reset(): void;
is(type: number): boolean;
}
export default Type;

26
node_modules/khroma/dist/channels/type.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/* IMPORT */
import { TYPE } from '../constants.js';
/* MAIN */
class Type {
constructor() {
/* VARIABLES */
this.type = TYPE.ALL;
}
/* API */
get() {
return this.type;
}
set(type) {
if (this.type && this.type !== type)
throw new Error('Cannot change both RGB and HSL channels at the same time');
this.type = type;
}
reset() {
this.type = TYPE.ALL;
}
is(type) {
return this.type === type;
}
}
/* EXPORT */
export default Type;