Release package version 0.0.1
All checks were successful
CI / build (push) Successful in 21s

Added first files
This commit is contained in:
Andrey Kernichniy 2026-03-07 15:41:31 +07:00
parent 8e1f2c6b8b
commit 37c748da0f
12 changed files with 93 additions and 3 deletions

View file

@ -41,7 +41,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: gxc-math-${{ github.sha }}
name: gxc-colors-${{ github.sha }}
path: ./dist/
deploy:
@ -53,7 +53,7 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: gxc-math-${{ github.sha }}
name: gxc-colors-${{ github.sha }}
path: ./artifact
- name: Setup Node.js

View file

@ -0,0 +1,2 @@
export * from "./interfaces";
export * from "./models";

View file

@ -0,0 +1,13 @@
export type ColorSpace = "rgb" | "cmyk";
export type ColorType = "rgb" | "cmyk" | "grayscale" | "spot";
export interface IColor {
readonly colorSpace: ColorSpace;
isTransparent: boolean;
equals(color: IColor): boolean;
clone(): IColor;
toString(): string;
toJSON(): object;
}
// export interface IProcessColor {}

0
lib/src/models/hsb.ts Normal file
View file

3
lib/src/models/index.ts Normal file
View file

@ -0,0 +1,3 @@
export * from "./rgb";
export * from "./swatch";
export * from "./palette";

0
lib/src/models/lab.ts Normal file
View file

View file

@ -0,0 +1 @@
export class Palette {}

62
lib/src/models/rgb.ts Normal file
View file

@ -0,0 +1,62 @@
import { ColorSpace, IColor } from "../interfaces";
export class RgbColor implements IColor {
readonly colorSpace: ColorSpace = "rgb";
get isTransparent() {
return this.a === 0;
}
constructor(
readonly r = 255,
readonly g = 255,
readonly b = 255,
readonly a = 255,
) {}
static fromHex(hex: string): RgbColor {
const normalized = hex.replace(/^#/, "");
const bigint = parseInt(normalized, 16);
const r = (bigint >> 16) & 255;
const g = (bigint >> 8) & 255;
const b = bigint & 255;
return new RgbColor(r, g, b);
}
toString() {
return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`;
}
equals(color: IColor) {
if (color instanceof RgbColor) {
return color.r === this.r && color.g === this.g && color.b === this.b && color.a === this.a;
}
return false;
}
clone() {
const a = this.a / 255;
return new RgbColor(this.r, this.g, this.b, a);
}
toHex() {
const r = Number(this.r).toString(16).padStart(2, "0");
const g = Number(this.g).toString(16).padStart(2, "0");
const b = Number(this.b).toString(16).padStart(2, "0");
return `#${r}${g}${b}`;
}
withoutAlpha() {
return new RgbColor(this.r, this.g, this.b, 255);
}
toJSON(): object {
return {
colorSpace: this.colorSpace,
r: this.r,
g: this.b,
b: this.b,
a: this.a,
};
}
}

0
lib/src/models/spot.ts Normal file
View file

6
lib/src/models/swatch.ts Normal file
View file

@ -0,0 +1,6 @@
import { IColor } from "../interfaces";
export class Swatch {
name: string;
color: IColor;
}

View file

@ -1,5 +1,5 @@
{
"name": "@gxc-solutions/lib",
"name": "@gxc-solutions/colors",
"version": "0.0.1",
"main": "index.js",
"author": "GXC Solutions",

View file

@ -0,0 +1,3 @@
# Description
@gxc-solutions/colors - is a library with models, utils and services for work with colors