Release package version 0.0.3
Update types of scene, added utils for check fill type.
This commit is contained in:
parent
eea082fbd2
commit
f106226e70
13 changed files with 126 additions and 38 deletions
1
.npmrc
Normal file
1
.npmrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
@gxc-solutions:registry=https://npm.gxc-solutions.ru/
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
export * from "./interfaces";
|
export * from "./interfaces";
|
||||||
|
export * from "./utils";
|
||||||
|
|
|
||||||
5
lib/src/interfaces/color.ts
Normal file
5
lib/src/interfaces/color.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface IRgbColor {
|
||||||
|
r: number;
|
||||||
|
g: number;
|
||||||
|
b: number;
|
||||||
|
}
|
||||||
40
lib/src/interfaces/fill.ts
Normal file
40
lib/src/interfaces/fill.ts
Normal 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,36 +1,5 @@
|
||||||
export type TRendererType = "2d" | "webgl" | "webgl2" | "webgpu" | "html";
|
export * from "./renderer";
|
||||||
|
export * from "./scene";
|
||||||
export type DrawObjectType = "rectangle-object" | "image-object" | "ellipse-object" | "text-object";
|
export * from "./objects";
|
||||||
|
export * from "./fill";
|
||||||
export interface IDrawObject extends IDrawBorderedRectangle {
|
export * from "./color";
|
||||||
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>;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
33
lib/src/interfaces/objects.ts
Normal file
33
lib/src/interfaces/objects.ts
Normal 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[];
|
||||||
|
}
|
||||||
9
lib/src/interfaces/renderer.ts
Normal file
9
lib/src/interfaces/renderer.ts
Normal 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>;
|
||||||
|
}
|
||||||
9
lib/src/interfaces/scene.ts
Normal file
9
lib/src/interfaces/scene.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { IBaseDrawObject, IDrawNode, IRectangle } from "./objects";
|
||||||
|
|
||||||
|
export interface IScene {
|
||||||
|
nodes: IDrawNode[];
|
||||||
|
selection?: IRectangle;
|
||||||
|
spotlight: IRectangle[];
|
||||||
|
background: string;
|
||||||
|
static: IBaseDrawObject[];
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "@gxc-solutions/renderer-base",
|
"name": "@gxc-solutions/renderer-base",
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "GXC Solutions",
|
"author": "GXC Solutions",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public",
|
"access": "public",
|
||||||
"registry": "https://npm.gxc-solutions.ru"
|
"registry": "https://npm.gxc-solutions.ru"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@gxc-solutions/math": "^0.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
7
lib/src/utils/fill.ts
Normal file
7
lib/src/utils/fill.ts
Normal 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
1
lib/src/utils/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export * from "./fill";
|
||||||
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -8,11 +8,19 @@
|
||||||
"name": "gxc-renderer-base",
|
"name": "gxc-renderer-base",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"@gxc-solutions/math": "^0.0.1"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"typescript": "^5.9.3"
|
"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": {
|
"node_modules/balanced-match": {
|
||||||
"version": "4.0.4",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {},
|
"dependencies": {
|
||||||
|
"@gxc-solutions/math": "^0.0.1"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue