Release package version 0.0.3
Some checks failed
CI / build (push) Failing after 13s
CI / deploy (push) Has been skipped

Update types of scene, added utils for check fill type.
This commit is contained in:
Andrey Kernichniy 2026-03-07 00:16:34 +07:00
parent eea082fbd2
commit f106226e70
13 changed files with 126 additions and 38 deletions

1
.npmrc Normal file
View file

@ -0,0 +1 @@
@gxc-solutions:registry=https://npm.gxc-solutions.ru/

View file

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

View file

@ -0,0 +1,5 @@
export interface IRgbColor {
r: number;
g: number;
b: number;
}

View file

@ -0,0 +1,40 @@
import { IRgbColor } from "./color";
import { IPoint } from "@gxc-solutions/math";
export type FillType = "solid" | "texture";
export type GradientType = "liner" | "radial" | "conic";
export interface IBaseFill {
type: GradientType | FillType;
}
export interface ISolidFill extends IBaseFill {
type: "solid";
color: IRgbColor;
}
export interface ITextureFill extends IBaseFill {
type: "texture";
texture: HTMLImageElement;
}
export interface IGradientStop {
offset: number;
color: IRgbColor;
}
export interface ILinerGradient extends IBaseFill {
type: "liner";
start: IPoint;
end: IPoint;
stops: IGradientStop[];
}
export interface IRadialGradient {
type: "radial";
}
export interface IConicGradient {
type: "conic";
}

View file

@ -1,36 +1,5 @@
export type TRendererType = "2d" | "webgl" | "webgl2" | "webgpu" | "html";
export type DrawObjectType = "rectangle-object" | "image-object" | "ellipse-object" | "text-object";
export interface IDrawObject extends IDrawBorderedRectangle {
readonly id: string;
readonly type: DrawObjectType;
color: string;
}
export interface IDrawRectangle {
x: number;
y: number;
width: number;
height: number;
angle: number;
}
export interface IDrawBorderedRectangle extends IDrawRectangle {
border: number;
borderColor: string;
}
export interface IScene {
objects: IDrawObject[];
selection?: IDrawRectangle;
spotlight: IDrawRectangle[];
background: string;
static: IDrawObject[];
}
export interface IRenderer {
readonly type: TRendererType;
holder: HTMLElement;
render(scene: IScene): Promise<void>;
}
export * from "./renderer";
export * from "./scene";
export * from "./objects";
export * from "./fill";
export * from "./color";

View file

@ -0,0 +1,33 @@
import { IRgbColor } from "./color";
import { IBaseFill } from "./fill";
export interface IRectangle {
x: number;
y: number;
width: number;
height: number;
angle: number;
}
export interface IStroke {
width: number;
color: IRgbColor;
dash: number[];
}
export type DrawObjectType = "rectangle-object" | "image-object" | "ellipse-object" | "text-object";
export interface IBaseDrawObject {
readonly id: string;
readonly type: DrawObjectType;
name: string;
}
export interface IDrawObject extends IBaseDrawObject {
stroke: IStroke;
fill: IBaseFill;
}
export interface IDrawNode extends IBaseDrawObject {
children: IDrawObject[];
}

View file

@ -0,0 +1,9 @@
import { IScene } from "./scene";
export type TRendererType = "2d" | "webgl" | "webgl2" | "webgpu" | "html";
export interface IRenderer {
readonly type: TRendererType;
holder: HTMLElement;
render(scene: IScene): Promise<void>;
}

View file

@ -0,0 +1,9 @@
import { IBaseDrawObject, IDrawNode, IRectangle } from "./objects";
export interface IScene {
nodes: IDrawNode[];
selection?: IRectangle;
spotlight: IRectangle[];
background: string;
static: IBaseDrawObject[];
}

View file

@ -1,10 +1,13 @@
{
"name": "@gxc-solutions/renderer-base",
"version": "0.0.2",
"version": "0.0.3",
"main": "index.js",
"author": "GXC Solutions",
"publishConfig": {
"access": "public",
"registry": "https://npm.gxc-solutions.ru"
},
"peerDependencies": {
"@gxc-solutions/math": "^0.0.1"
}
}

7
lib/src/utils/fill.ts Normal file
View file

@ -0,0 +1,7 @@
import { IBaseFill, IConicGradient, ILinerGradient, IRadialGradient, ISolidFill, ITextureFill } from "../interfaces/fill";
export const isSolidFill = (fill: IBaseFill): fill is ISolidFill => fill?.type === "solid";
export const isTextureFill = (fill: IBaseFill): fill is ITextureFill => fill?.type === "texture";
export const isLinerGradientFill = (fill: IBaseFill): fill is ILinerGradient => fill?.type === "liner";
export const isRadialGradientFill = (fill: IBaseFill): fill is IRadialGradient => fill?.type === "radial";
export const isConicGradientFill = (fill: IBaseFill): fill is IConicGradient => fill?.type === "conic";

1
lib/src/utils/index.ts Normal file
View file

@ -0,0 +1 @@
export * from "./fill";

8
package-lock.json generated
View file

@ -8,11 +8,19 @@
"name": "gxc-renderer-base",
"version": "0.0.0",
"license": "ISC",
"dependencies": {
"@gxc-solutions/math": "^0.0.1"
},
"devDependencies": {
"rimraf": "^6.0.1",
"typescript": "^5.9.3"
}
},
"node_modules/@gxc-solutions/math": {
"version": "0.0.1",
"resolved": "https://npm.gxc-solutions.ru/@gxc-solutions/math/-/math-0.0.1.tgz",
"integrity": "sha512-m6lxTkjXkyaUoI3+cJKpgt/AQlyApLSJ2p9D2EJ9+XzHCSjOWs29GzczPLgopYdLEWYN/YPr77V4CScGpR7qxw=="
},
"node_modules/balanced-match": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",

View file

@ -10,7 +10,9 @@
"author": "",
"license": "ISC",
"description": "",
"dependencies": {},
"dependencies": {
"@gxc-solutions/math": "^0.0.1"
},
"devDependencies": {
"rimraf": "^6.0.1",
"typescript": "^5.9.3"