diff --git a/example/pong/src/components.ts b/example/pong/src/components.ts index 05f58ae..78e5c34 100644 --- a/example/pong/src/components.ts +++ b/example/pong/src/components.ts @@ -1,7 +1,8 @@ -import type { NfgCircle } from "@nanoforge/graphics-2d"; -import type { NfgRectangle } from "@nanoforge/graphics-2d/src/components/shape/shapes/rectangle.shape"; +import type { Graphics } from "@nanoforge/graphics-2d"; import type { InputEnum } from "@nanoforge/input"; +import { layer } from "./index"; + export class Velocity { name = "Velocity"; x: number; @@ -37,19 +38,21 @@ export class Hitbox { export class CircleComponent { name = "CircleComponent"; - component: NfgCircle; + component: Graphics.Circle; - constructor(component: NfgCircle) { + constructor(component: Graphics.Circle) { this.component = component; + layer.add(this.component); } } export class RectangleComponent { name = "RectangleComponent"; - component: NfgRectangle; + component: Graphics.Rect; - constructor(component: NfgRectangle) { + constructor(component: Graphics.Rect) { this.component = component; + layer.add(this.component); } } diff --git a/example/pong/src/index.ts b/example/pong/src/index.ts index 004aea7..19d315d 100644 --- a/example/pong/src/index.ts +++ b/example/pong/src/index.ts @@ -2,9 +2,8 @@ import { AssetManagerLibrary } from "@nanoforge/asset-manager"; import { type IRunOptions } from "@nanoforge/common"; import { NanoforgeFactory } from "@nanoforge/core"; import { ECSLibrary } from "@nanoforge/ecs"; -import { Graphics2DLibrary } from "@nanoforge/graphics-2d"; -import { InputLibrary } from "@nanoforge/input"; -import { InputEnum } from "@nanoforge/input"; +import { Graphics, Graphics2DLibrary } from "@nanoforge/graphics-2d"; +import { InputEnum, InputLibrary } from "@nanoforge/input"; import { SoundLibrary } from "@nanoforge/sound"; import { @@ -16,7 +15,7 @@ import { RectangleComponent, Velocity, } from "./components"; -import { bounce, controlPlayer, drawCircle, drawRectangle, move, moveRectangle } from "./systems"; +import { bounce, controlPlayer, drawCircle, move, moveRectangle } from "./systems"; export const ecsLibrary = new ECSLibrary(); @@ -26,6 +25,8 @@ export const inputs = new InputLibrary(); export const sounds = new SoundLibrary(); export const assetManager = new AssetManagerLibrary(); +export const layer = new Graphics.Layer(); + export const main = async (options: IRunOptions) => { app.useGraphics(graphics); app.useComponentSystem(ecsLibrary); @@ -35,90 +36,51 @@ export const main = async (options: IRunOptions) => { await app.init(options); + graphics.stage.add(layer); + console.log(graphics.stage.width()); + sounds.load("test", "https://universal-soundbank.com/sounds/18782.mp3"); const ball = ecsLibrary.spawnEntity(); - ecsLibrary.addComponent(ball, new Velocity(0.04, 0)); - ecsLibrary.addComponent(ball, new Position(0.5, 0)); - ecsLibrary.addComponent(ball, new Bounce()); + ecsLibrary.addComponent(ball, new Velocity(10, 0)); ecsLibrary.addComponent( ball, - new CircleComponent( - await graphics.factory.createCircle({ - radius: 0.1, - color: { r: 1, g: 0, b: 0, a: 1 }, - }), - ), - ); - - const bg = ecsLibrary.spawnEntity(); - ecsLibrary.addComponent( - bg, - new RectangleComponent( - await graphics.factory.createRectangle({ - min: { x: -2, y: -1 }, - max: { x: 2, y: 1 }, - color: { r: 0, g: 0, b: 0, a: 0 }, - }), - ), - ); - - const topWall = ecsLibrary.spawnEntity(); - ecsLibrary.addComponent( - topWall, - new RectangleComponent( - await graphics.factory.createRectangle({ - color: { r: 0, g: 0, b: 0, a: 1 }, - }), - ), + new Position(graphics.stage.width() / 2, graphics.stage.height() / 2), ); - ecsLibrary.addComponent(topWall, new Position(-1.8, 0.91)); - ecsLibrary.addComponent(topWall, new Hitbox(3.6, 0.1)); - - const botWall = ecsLibrary.spawnEntity(); + ecsLibrary.addComponent(ball, new Bounce()); ecsLibrary.addComponent( - botWall, - new RectangleComponent( - await graphics.factory.createRectangle({ - color: { r: 0, g: 0, b: 0, a: 1 }, + ball, + new CircleComponent( + new Graphics.Circle({ + radius: 70, + fill: "red", }), ), ); - ecsLibrary.addComponent(botWall, new Position(-1.8, -1)); - ecsLibrary.addComponent(botWall, new Hitbox(3.6, 0.1)); const player1 = ecsLibrary.spawnEntity(); - ecsLibrary.addComponent(player1, new Position(-1.8, -0.3)); - ecsLibrary.addComponent(player1, new Velocity(0, 0.1)); - ecsLibrary.addComponent(player1, new Hitbox(0.1, 0.5)); + ecsLibrary.addComponent(player1, new Position(20, 100)); + ecsLibrary.addComponent(player1, new Velocity(0, 5)); + ecsLibrary.addComponent(player1, new Hitbox(50, 500)); ecsLibrary.addComponent(player1, new Controller(InputEnum.KeyW, InputEnum.KeyS)); ecsLibrary.addComponent( player1, - new RectangleComponent( - await graphics.factory.createRectangle({ - color: { r: 0, g: 0, b: 1, a: 1 }, - }), - ), + new RectangleComponent(new Graphics.Rect({ fill: "blue", width: 50, height: 500 })), ); const player2 = ecsLibrary.spawnEntity(); - ecsLibrary.addComponent(player2, new Position(1.7, -0.3)); - ecsLibrary.addComponent(player2, new Velocity(0, 0.1)); - ecsLibrary.addComponent(player2, new Hitbox(0.1, 0.5)); + ecsLibrary.addComponent(player2, new Position(1850, 100)); + ecsLibrary.addComponent(player2, new Velocity(0, 5)); + ecsLibrary.addComponent(player2, new Hitbox(50, 500)); ecsLibrary.addComponent(player2, new Controller(InputEnum.ArrowUp, InputEnum.ArrowDown)); ecsLibrary.addComponent( player2, - new RectangleComponent( - await graphics.factory.createRectangle({ - color: { r: 0, g: 0, b: 1, a: 1 }, - }), - ), + new RectangleComponent(new Graphics.Rect({ fill: "blue", width: 50, height: 500 })), ); ecsLibrary.addSystem(move); ecsLibrary.addSystem(controlPlayer); ecsLibrary.addSystem(moveRectangle); - ecsLibrary.addSystem(drawRectangle); ecsLibrary.addSystem(drawCircle); ecsLibrary.addSystem(bounce); diff --git a/example/pong/src/systems.ts b/example/pong/src/systems.ts index cc55d67..657c39d 100644 --- a/example/pong/src/systems.ts +++ b/example/pong/src/systems.ts @@ -8,7 +8,7 @@ import { RectangleComponent, Velocity, } from "./components"; -import { ecsLibrary, graphics, inputs, sounds } from "./index"; +import { ecsLibrary, inputs, sounds } from "./index"; export function move() { const entities = ecsLibrary.getZipper([Bounce, Position, Velocity]); @@ -23,12 +23,12 @@ export function bounce() { const entities = ecsLibrary.getZipper([Bounce, Position, Velocity]); entities.forEach((entity) => { - if (entity.Position.x >= 1.6 || entity.Position.x <= -1.6) { + if (entity.Position.x >= 1800 || entity.Position.x <= 100) { entity.Velocity.x = -entity.Velocity.x; sounds.play("test"); } - if (entity.Position.y >= 1 || entity.Position.y <= -1) { + if (entity.Position.y >= 1000 || entity.Position.y <= 100) { entity.Velocity.y = -entity.Velocity.y; sounds.play("test"); @@ -41,14 +41,14 @@ export function controlPlayer() { entities.forEach((entity) => { if (inputs.isKeyPressed(entity.Controller.up) && !checkCollisions(entity)) { - entity.Position.y += entity.Velocity.y; - } else { entity.Position.y -= entity.Velocity.y; + } else { + entity.Position.y += entity.Velocity.y; } if (inputs.isKeyPressed(entity.Controller.down) && !checkCollisions(entity)) { - entity.Position.y -= entity.Velocity.y; - } else { entity.Position.y += entity.Velocity.y; + } else { + entity.Position.y -= entity.Velocity.y; } }); } @@ -59,27 +59,15 @@ export function drawCircle() { entities.forEach((entity) => { const pos = entity.Position; entity.CircleComponent.component.setPosition(pos); - graphics.getWindow().draw(entity.CircleComponent.component); }); } export function moveRectangle() { const entities = ecsLibrary.getZipper([RectangleComponent, Position, Hitbox]); + console.log(entities); entities.forEach((entity) => { const pos = entity.Position; - entity.RectangleComponent.component.setMin({ x: pos.x, y: pos.y }); - entity.RectangleComponent.component.setMax({ - x: pos.x + entity.Hitbox.width, - y: pos.y + entity.Hitbox.height, - }); - }); -} - -export function drawRectangle() { - const entities = ecsLibrary.getZipper([RectangleComponent]); - - entities.forEach((entity) => { - graphics.getWindow().draw(entity.RectangleComponent.component); + (entity.RectangleComponent as RectangleComponent).component.setPosition(pos); }); } diff --git a/packages/asset-manager/jest.config.json b/packages/asset-manager/jest.config.json index b75e6b6..6b46991 100644 --- a/packages/asset-manager/jest.config.json +++ b/packages/asset-manager/jest.config.json @@ -1,4 +1,5 @@ { + "preset": "ts-jest", "moduleFileExtensions": ["js", "json", "ts"], "rootDir": "test", "collectCoverageFrom": ["**/*.(t|j)s"], @@ -7,6 +8,7 @@ "transform": { "^.+\\.(t|j)s$": "ts-jest" }, + "transformIgnorePatterns": ["/node_modules/"], "verbose": true, "testTimeout": 5000 } diff --git a/packages/ecs/jest.config.json b/packages/ecs/jest.config.json index b75e6b6..6b46991 100644 --- a/packages/ecs/jest.config.json +++ b/packages/ecs/jest.config.json @@ -1,4 +1,5 @@ { + "preset": "ts-jest", "moduleFileExtensions": ["js", "json", "ts"], "rootDir": "test", "collectCoverageFrom": ["**/*.(t|j)s"], @@ -7,6 +8,7 @@ "transform": { "^.+\\.(t|j)s$": "ts-jest" }, + "transformIgnorePatterns": ["/node_modules/"], "verbose": true, "testTimeout": 5000 } diff --git a/packages/graphics-2d/jest.config.json b/packages/graphics-2d/jest.config.json index b75e6b6..6b46991 100644 --- a/packages/graphics-2d/jest.config.json +++ b/packages/graphics-2d/jest.config.json @@ -1,4 +1,5 @@ { + "preset": "ts-jest", "moduleFileExtensions": ["js", "json", "ts"], "rootDir": "test", "collectCoverageFrom": ["**/*.(t|j)s"], @@ -7,6 +8,7 @@ "transform": { "^.+\\.(t|j)s$": "ts-jest" }, + "transformIgnorePatterns": ["/node_modules/"], "verbose": true, "testTimeout": 5000 } diff --git a/packages/graphics-2d/package.json b/packages/graphics-2d/package.json index 1982728..5056c13 100644 --- a/packages/graphics-2d/package.json +++ b/packages/graphics-2d/package.json @@ -33,7 +33,8 @@ }, "dependencies": { "@nanoforge/asset-manager": "workspace:^", - "@nanoforge/common": "workspace:^" + "@nanoforge/common": "workspace:^", + "konva": "^10.0.2" }, "devDependencies": { "@nanoforge/utils-eslint-config": "workspace:^", diff --git a/packages/graphics-2d/src/components/component.ts b/packages/graphics-2d/src/components/component.ts deleted file mode 100644 index 7867897..0000000 --- a/packages/graphics-2d/src/components/component.ts +++ /dev/null @@ -1,136 +0,0 @@ -import type { GraphicsCore } from "../core"; -import type { ShaderManager } from "../shader/shader.manager"; - -export abstract class NfgComponent { - private readonly _core: GraphicsCore; - protected readonly _shaderManager: ShaderManager; - private _vertices: Float32Array; - protected _vertexBuffer: GPUBuffer; - protected abstract _vertexLength: number; - protected abstract readonly _vertexBufferLayout: GPUVertexBufferLayout; - private _uniformBuffer: GPUBuffer; - protected abstract _shader: GPUShaderModule; - private _pipeline: GPURenderPipeline; - private readonly _pipelineLayout: GPUPipelineLayout; - private readonly _label: string; - private _bindGroup: GPUBindGroup; - protected _duplicate: number = 1; - - constructor(core: GraphicsCore) { - this._core = core; - this._shaderManager = core.shaderManager; - this._label = `${this.constructor.name} - ${Date.now()}`; - - const bindGroupLayout = this._core.device.createBindGroupLayout({ - label: `${this._label} Bind Group Layout`, - entries: [ - { - binding: 0, - visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT, - buffer: {}, - }, - ], - }); - - this._pipelineLayout = this._core.device.createPipelineLayout({ - label: `${this._label} Pipeline Layout`, - bindGroupLayouts: [bindGroupLayout], - }); - } - - public async init(): Promise { - await this._init(); - this.updateUniforms(); - this._updatePipeline(); - return this; - } - - public draw(pass: GPURenderPassEncoder): void { - pass.setPipeline(this._pipeline); - pass.setBindGroup(0, this._bindGroup); - pass.setVertexBuffer(0, this._vertexBuffer); - pass.draw(this._vertices.length / this._vertexLength, this._duplicate); - } - - public updateUniforms(): void { - const uniformArray = new Float32Array([ - 0, - 0, - 0, - 1, - 1, - 1, - this._core.initContext.canvas.width, - this._core.initContext.canvas.height, - ]); - - if (!this._uniformBuffer) - this._uniformBuffer = this._core.device.createBuffer({ - label: "View Uniforms", - size: uniformArray.byteLength, - usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, - }); - this._core.device.queue.writeBuffer(this._uniformBuffer, 0, uniformArray); - } - - protected abstract _init(): Promise; - - protected _setVertices(raw: number[]): void { - const len = this._vertices?.byteLength ?? -1; - this._vertices = new Float32Array(raw); - if (len !== this._vertices.byteLength) this._updateVertexBuffer(); - else this._writeVertexBuffer(); - } - - protected _updateVertexBuffer(): void { - this._vertexBuffer = this._core.device.createBuffer({ - label: `${this._label} vertices`, - size: this._vertices.byteLength, - usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST, - }); - this._writeVertexBuffer(); - } - - protected _writeVertexBuffer(): void { - this._core.device.queue.writeBuffer( - this._vertexBuffer, - 0, - this._vertices as unknown as SharedArrayBuffer, - ); - } - - protected _updatePipeline(): void { - this._pipeline = this._core.device.createRenderPipeline({ - label: `${this._label} pipeline`, - layout: this._pipelineLayout, - vertex: { - module: this._shader, - entryPoint: "vertex_main", - buffers: [this._vertexBufferLayout], - }, - fragment: { - module: this._shader, - entryPoint: "fragment_main", - targets: [ - { - format: this._core.render.canvasFormat, - }, - ], - }, - }); - this._updateBindGroup(); - } - - protected _updateBindGroup(): void { - this._bindGroup = this._core.device.createBindGroup({ - label: `${this._label} renderer bind group`, - layout: this._pipeline.getBindGroupLayout(0), - entries: [ - { - binding: 0, - resource: { buffer: this._uniformBuffer }, - }, - ], - }); - } -} diff --git a/packages/graphics-2d/src/components/index.ts b/packages/graphics-2d/src/components/index.ts deleted file mode 100644 index 90d87fc..0000000 --- a/packages/graphics-2d/src/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { NfgComponent } from "./component"; -export * from "./shape"; diff --git a/packages/graphics-2d/src/components/shape/common/shape.ts b/packages/graphics-2d/src/components/shape/common/shape.ts deleted file mode 100644 index f136e97..0000000 --- a/packages/graphics-2d/src/components/shape/common/shape.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { NfgComponent } from "../../component"; - -export abstract class NfgShape extends NfgComponent {} diff --git a/packages/graphics-2d/src/components/shape/index.ts b/packages/graphics-2d/src/components/shape/index.ts deleted file mode 100644 index 0b1d008..0000000 --- a/packages/graphics-2d/src/components/shape/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { NfgShape } from "./common/shape"; -export * from "./shapes"; diff --git a/packages/graphics-2d/src/components/shape/shapes/circle.shape.ts b/packages/graphics-2d/src/components/shape/shapes/circle.shape.ts deleted file mode 100644 index bbe369b..0000000 --- a/packages/graphics-2d/src/components/shape/shapes/circle.shape.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { type GraphicsCore } from "../../../core"; -import { ShadersEnum } from "../../../shader/shaders.enum"; -import { type ICircleOptions, type IColor, type IVertex2D } from "../../../types"; -import { NfgShape } from "../common/shape"; - -export class NfgCircle extends NfgShape { - protected _shader: GPUShaderModule; - protected readonly _vertexBufferLayout: GPUVertexBufferLayout; - protected _vertexLength: number; - - private _pos: IVertex2D; - private _radius: number; - private _color: IColor; - - constructor(core: GraphicsCore, options?: Partial) { - super(core); - - this._vertexBufferLayout = { - arrayStride: 28, - attributes: [ - { - format: "float32x2", - offset: 0, - shaderLocation: 0, - }, - { - format: "float32", - offset: 8, - shaderLocation: 1, - }, - { - format: "float32x4", - offset: 12, - shaderLocation: 2, - }, - ], - }; - this._vertexLength = 7; - - this._pos = options?.pos ?? { x: 0, y: 0 }; - this._radius = options?.radius ?? 0.1; - this._color = options?.color ?? { r: 0, g: 0, b: 0, a: 1 }; - this._updateVertices(); - } - - public setPosition(pos: IVertex2D): NfgCircle { - this._pos = pos; - this._updateVertices(); - return this; - } - - public setRadius(radius: number): NfgCircle { - this._radius = radius; - this._updateVertices(); - return this; - } - - public setColor(color: IColor): NfgCircle { - this._color = color; - this._updateVertices(); - return this; - } - - protected async _init(): Promise { - this._shader = await this._shaderManager.get(ShadersEnum.CIRCLE); - } - - protected _updateVertices(): void { - this._setVertices([ - this._pos.x, - this._pos.y, - this._radius, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - this._pos.x, - this._pos.y, - this._radius, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - this._pos.x, - this._pos.y, - this._radius, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - ]); - } -} diff --git a/packages/graphics-2d/src/components/shape/shapes/index.ts b/packages/graphics-2d/src/components/shape/shapes/index.ts deleted file mode 100644 index e306fef..0000000 --- a/packages/graphics-2d/src/components/shape/shapes/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { NfgCircle } from "./circle.shape"; -export { NfgRectangle } from "./rectangle.shape"; diff --git a/packages/graphics-2d/src/components/shape/shapes/rectangle.shape.ts b/packages/graphics-2d/src/components/shape/shapes/rectangle.shape.ts deleted file mode 100644 index 0c70e3a..0000000 --- a/packages/graphics-2d/src/components/shape/shapes/rectangle.shape.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { type GraphicsCore } from "../../../core"; -import { ShadersEnum } from "../../../shader/shaders.enum"; -import { type IColor, type IRectangleOptions, type IVertex2D } from "../../../types"; -import { NfgShape } from "../common/shape"; - -export class NfgRectangle extends NfgShape { - protected _shader: GPUShaderModule; - protected readonly _vertexBufferLayout: GPUVertexBufferLayout; - protected _vertexLength: number; - - private _min: IVertex2D; - private _max: IVertex2D; - private _color: IColor; - - constructor(core: GraphicsCore, options?: Partial) { - super(core); - - this._vertexBufferLayout = { - arrayStride: 32, - attributes: [ - { - format: "float32x2", - offset: 0, - shaderLocation: 0, - }, - { - format: "float32x2", - offset: 8, - shaderLocation: 1, - }, - { - format: "float32x4", - offset: 16, - shaderLocation: 2, - }, - ], - }; - this._vertexLength = 8; - - this._duplicate = 1; - - this._min = options?.min ?? { x: 0, y: 0 }; - this._max = options?.max ?? { x: 0, y: 0 }; - this._color = options?.color ?? { r: 0, g: 0, b: 0, a: 1 }; - this._updateVertices(); - } - - public setMin(pos: IVertex2D): NfgRectangle { - this._min = pos; - this._updateVertices(); - return this; - } - - public setMax(pos: IVertex2D): NfgRectangle { - this._max = pos; - this._updateVertices(); - return this; - } - - public setColor(color: IColor): NfgRectangle { - this._color = color; - this._updateVertices(); - return this; - } - - protected async _init(): Promise { - this._shader = await this._shaderManager.get(ShadersEnum.RECTANGLE); - } - - protected _updateVertices(): void { - this._setVertices([ - this._min.x, - this._min.y, - this._max.x, - this._max.y, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - this._min.x, - this._min.y, - this._max.x, - this._max.y, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - this._min.x, - this._min.y, - this._max.x, - this._max.y, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - this._min.x, - this._min.y, - this._max.x, - this._max.y, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - this._min.x, - this._min.y, - this._max.x, - this._max.y, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - this._min.x, - this._min.y, - this._max.x, - this._max.y, - this._color.r, - this._color.g, - this._color.b, - this._color.a, - ]); - } -} diff --git a/packages/graphics-2d/src/core.ts b/packages/graphics-2d/src/core.ts deleted file mode 100644 index e957385..0000000 --- a/packages/graphics-2d/src/core.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { type InitContext } from "@nanoforge/common"; - -import { GraphicsRender } from "./render"; -import { NfgWindow } from "./render/window"; -import { ShaderManager } from "./shader/shader.manager"; - -export class GraphicsCore { - private readonly _initContext: InitContext; - - private readonly _shaderManager: ShaderManager; - private _render: GraphicsRender; - private _window: NfgWindow; - - private _adapter: GPUAdapter; - private _device: GPUDevice; - - constructor(context: InitContext) { - this._initContext = context; - - this._shaderManager = new ShaderManager(this); - } - - get initContext(): InitContext { - return this._initContext; - } - - get adapter(): GPUAdapter { - return this._adapter; - } - - get device(): GPUDevice { - return this._device; - } - - get shaderManager(): ShaderManager { - return this._shaderManager; - } - - get render(): GraphicsRender { - return this._render; - } - - get window(): NfgWindow { - return this._window; - } - - public async init(): Promise { - if (!navigator.gpu) { - throw new Error("WebGPU not supported on this browser."); - } - - const adapter = await navigator.gpu.requestAdapter(); - if (!adapter) { - throw new Error("No appropriate GPUAdapter found."); - } - this._adapter = adapter; - - const device = await this._adapter.requestDevice(); - if (!device) { - throw new Error("No appropriate GPUDevice found."); - } - this._device = device; - - this._render = new GraphicsRender(this, this._initContext); - this._window = new NfgWindow(this._render); - } -} diff --git a/packages/graphics-2d/src/exports/konva.ts b/packages/graphics-2d/src/exports/konva.ts new file mode 100644 index 0000000..cbc371b --- /dev/null +++ b/packages/graphics-2d/src/exports/konva.ts @@ -0,0 +1,231 @@ +import Konva from "konva"; + +export const Animation = Konva.Animation; +export type Animation = Konva.Animation; + +export const Arc = Konva.Arc; +export type Arc = Konva.Arc; + +export type ArcConfig = Konva.ArcConfig; + +export const Arrow = Konva.Arrow; +export type Arrow = Konva.Arrow; + +export type ArrowConfig = Konva.ArrowConfig; + +export const Canvas = Konva.Canvas; +export type Canvas = typeof Konva.Canvas; + +export const Circle = Konva.Circle; +export type Circle = Konva.Circle; + +export type CircleConfig = Konva.CircleConfig; + +export const Container = Konva.Container; +export type Container = Konva.Container; + +export type ContainerConfig = Konva.ContainerConfig; + +export const Context = Konva.Context; +export type Context = Konva.Context; + +export const DD = Konva.DD; +export type DD = typeof Konva.DD; + +export const Easings = Konva.Easings; +export type Easings = typeof Konva.Easings; + +export const Ellipse = Konva.Ellipse; +export type Ellipse = Konva.Ellipse; + +export type EllipseConfig = Konva.EllipseConfig; + +export const FastLayer = Konva.FastLayer; +export type FastLayer = Konva.FastLayer; + +export const Filters = Konva.Filters; +export type Filters = typeof Konva.Filters; + +export const Group = Konva.Group; +export type Group = Konva.Group; + +export type GroupConfig = Konva.GroupConfig; + +export const Image = Konva.Image; +export type Image = Konva.Image; + +export type ImageConfig = Konva.ImageConfig; + +export type KonvaEventListener = Konva.KonvaEventListener; + +export type KonvaEventObject = Konva.KonvaEventObject; + +export type KonvaPointerEvent = Konva.KonvaPointerEvent; + +export const Label = Konva.Label; +export type Label = Konva.Label; + +export type LabelConfig = Konva.LabelConfig; + +export const Layer = Konva.Layer; +export type Layer = Konva.Layer; + +export type LayerConfig = Konva.LayerConfig; + +export const Line = Konva.Line; +export type Line = Konva.Line; + +export type LineConfig = Konva.LineConfig; + +export const Node = Konva.Node; +export type Node = Konva.Node; + +export type NodeConfig = Konva.NodeConfig; + +export const Path = Konva.Path; +export type Path = Konva.Path; + +export type PathConfig = Konva.PathConfig; + +export const Rect = Konva.Rect; +export type Rect = Konva.Rect; + +export type RectConfig = Konva.RectConfig; + +export const RegularPolygon = Konva.RegularPolygon; +export type RegularPolygon = Konva.RegularPolygon; + +export type RegularPolygonConfig = Konva.RegularPolygonConfig; + +export const Ring = Konva.Ring; +export type Ring = Konva.Ring; + +export type RingConfig = Konva.RingConfig; + +export const Shape = Konva.Shape; +export type Shape = Konva.Shape; + +export type ShapeConfig = Konva.ShapeConfig; + +export const Sprite = Konva.Sprite; +export type Sprite = Konva.Sprite; + +export type SpriteConfig = Konva.SpriteConfig; + +export const Stage = Konva.Stage; +export type Stage = Konva.Stage; + +export type StageConfig = Konva.StageConfig; + +export const Star = Konva.Star; +export type Star = Konva.Star; + +export type StarConfig = Konva.StarConfig; + +export const Tag = Konva.Tag; +export type Tag = Konva.Tag; + +export type TagConfig = Konva.TagConfig; + +export const Text = Konva.Text; +export type Text = Konva.Text; + +export type TextConfig = Konva.TextConfig; + +export const TextPath = Konva.TextPath; +export type TextPath = Konva.TextPath; + +export type TextPathConfig = Konva.TextPathConfig; + +export const Transform = Konva.Transform; +export type Transform = Konva.Transform; + +export const Transformer = Konva.Transformer; +export type Transformer = Konva.Transformer; + +export type TransformerConfig = Konva.TransformerConfig; + +export const Tween = Konva.Tween; +export type Tween = Konva.Tween; + +export type TweenConfig = Konva.TweenConfig; + +export const Util = Konva.Util; +export type Util = typeof Konva.Util; + +export type Vector2d = Konva.Vector2d; + +export const Wedge = Konva.Wedge; +export type Wedge = Konva.Wedge; + +export type WedgeConfig = Konva.WedgeConfig; + +export const _global = Konva._global; + +export const _injectGlobal = Konva._injectGlobal; + +export const _mouseDblClickPointerId = Konva._mouseDblClickPointerId; + +export const _mouseInDblClickWindow = Konva._mouseInDblClickWindow; + +export const _mouseListenClick = Konva._mouseListenClick; + +export const _pointerDblClickPointerId = Konva._pointerDblClickPointerId; + +export const _pointerInDblClickWindow = Konva._pointerInDblClickWindow; + +export const _pointerListenClick = Konva._pointerListenClick; + +export const _renderBackend = Konva._renderBackend; + +export const _touchDblClickPointerId = Konva._touchDblClickPointerId; + +export const _touchInDblClickWindow = Konva._touchInDblClickWindow; + +export const _touchListenClick = Konva._touchListenClick; + +export const angleDeg = Konva.angleDeg; + +export const autoDrawEnabled = Konva.autoDrawEnabled; + +export const capturePointerEventsEnabled = Konva.capturePointerEventsEnabled; + +export const dblClickWindow = Konva.dblClickWindow; + +export const document = Konva.document; + +export const dragButtons = Konva.dragButtons; + +export const dragDistance = Konva.dragDistance; + +export const enableTrace = Konva.enableTrace; + +export const getAngle = Konva.getAngle; + +export const hitOnDragEnabled = Konva.hitOnDragEnabled; + +export const isBrowser = Konva.isBrowser; + +export const isDragReady = Konva.isDragReady; + +export const isDragging = Konva.isDragging; + +export const isTransforming = Konva.isTransforming; + +export const isUnminified = Konva.isUnminified; + +export const legacyTextRendering = Konva.legacyTextRendering; + +export const pixelRatio = Konva.pixelRatio; + +export const pointerEventsEnabled = Konva.pointerEventsEnabled; + +export const releaseCanvasOnDestroy = Konva.releaseCanvasOnDestroy; + +export const shapes = Konva.shapes; + +export const showWarnings = Konva.showWarnings; + +export const stages = Konva.stages; + +export const version = Konva.version; diff --git a/packages/graphics-2d/src/factory.ts b/packages/graphics-2d/src/factory.ts deleted file mode 100644 index 8575c9f..0000000 --- a/packages/graphics-2d/src/factory.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NfgCircle, NfgRectangle } from "./components"; -import { type GraphicsCore } from "./core"; -import { type ICircleOptions, type IRectangleOptions } from "./types"; - -export class GraphicsFactory { - private readonly _core: GraphicsCore; - - constructor(core: GraphicsCore) { - this._core = core; - } - - createCircle(options?: Partial): Promise { - return new NfgCircle(this._core, options).init(); - } - - createRectangle(options?: Partial): Promise { - return new NfgRectangle(this._core, options).init(); - } -} diff --git a/packages/graphics-2d/src/graphics-2d.library.ts b/packages/graphics-2d/src/graphics-2d.library.ts index 8406d88..5640a77 100644 --- a/packages/graphics-2d/src/graphics-2d.library.ts +++ b/packages/graphics-2d/src/graphics-2d.library.ts @@ -1,41 +1,28 @@ -import { ASSET_MANAGER_LIBRARY, BaseGraphicsLibrary, type InitContext } from "@nanoforge/common"; +import { BaseGraphicsLibrary, type InitContext } from "@nanoforge/common"; -import { GraphicsCore } from "./core"; -import { GraphicsFactory } from "./factory"; -import { type NfgWindow } from "./render/window"; +import { Graphics } from "."; export class Graphics2DLibrary extends BaseGraphicsLibrary { - private _core: GraphicsCore; - private _factory: GraphicsFactory; - - constructor() { - super({ - dependencies: [ASSET_MANAGER_LIBRARY], - }); - } + private _stage: Graphics.Stage; get name(): string { return "Graphics2DLibrary"; } - get factory(): GraphicsFactory { - return this._factory; + get stage(): Graphics.Stage { + return this._stage; } public async init(context: InitContext): Promise { if (!context.canvas) { throw new Error("Can't initialize the canvas context"); } - this._core = new GraphicsCore(context); - await this._core.init(); - this._factory = new GraphicsFactory(this._core); - } - - public async run(): Promise { - this._core.window.render(); + this._stage = new Graphics.Stage({ + container: context.canvas.parentElement as HTMLDivElement, + width: window.innerWidth, + height: window.innerHeight, + }); } - public getWindow(): NfgWindow { - return this._core.window; - } + public async run(): Promise {} } diff --git a/packages/graphics-2d/src/index.ts b/packages/graphics-2d/src/index.ts index 3199628..c856cf0 100644 --- a/packages/graphics-2d/src/index.ts +++ b/packages/graphics-2d/src/index.ts @@ -1,5 +1,2 @@ -import "./shader/shaders"; - -export * from "./types"; -export * from "./components"; export { Graphics2DLibrary } from "./graphics-2d.library"; +export * as Graphics from "./exports/konva"; diff --git a/packages/graphics-2d/src/render.ts b/packages/graphics-2d/src/render.ts deleted file mode 100644 index 3c26b4f..0000000 --- a/packages/graphics-2d/src/render.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { type InitContext } from "@nanoforge/common"; - -import { type NfgComponent } from "./components"; -import { type GraphicsCore } from "./core"; - -export class GraphicsRender { - private readonly _core: GraphicsCore; - private readonly _canvas: HTMLCanvasElement; - private readonly _canvasContext: GPUCanvasContext; - private readonly _canvasFormat: GPUTextureFormat; - - constructor(core: GraphicsCore, initContext: InitContext) { - this._core = core; - - this._canvas = initContext.canvas; - - const context = initContext.canvas.getContext("webgpu"); - if (!context) { - throw new Error("Could not get canvas context."); - } - this._canvasContext = context; - - this._canvasFormat = navigator.gpu.getPreferredCanvasFormat(); - - this._canvasContext.configure({ - device: this._core.device, - format: this._canvasFormat, - alphaMode: "premultiplied", - }); - } - - get canvas(): HTMLCanvasElement { - return this._canvas; - } - - get canvasFormat(): GPUTextureFormat { - return this._canvasFormat; - } - - render(components: NfgComponent[]): void { - const [encoder, pass] = this._beginRender(); - this._renderComponents(pass, components); - this._endRender(pass, encoder); - } - - private _beginRender(): [GPUCommandEncoder, GPURenderPassEncoder] { - const encoder = this._core.device.createCommandEncoder(); - - const pass = encoder.beginRenderPass({ - colorAttachments: [ - { - view: this._canvasContext.getCurrentTexture().createView(), - loadOp: "clear", - clearValue: { r: 0, g: 0, b: 0.4, a: 1.0 }, - storeOp: "store", - }, - ], - }); - - return [encoder, pass]; - } - - private _renderComponents(pass: GPURenderPassEncoder, components: NfgComponent[]): void { - for (const component of components) { - component.draw(pass); - } - } - - private _endRender(pass: GPURenderPassEncoder, encoder: GPUCommandEncoder): void { - pass.end(); - this._core.device.queue.submit([encoder.finish()]); - } -} diff --git a/packages/graphics-2d/src/render/window.ts b/packages/graphics-2d/src/render/window.ts deleted file mode 100644 index 0ffa959..0000000 --- a/packages/graphics-2d/src/render/window.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { type NfgComponent } from "../components/component"; -import { type GraphicsRender } from "../render"; - -export class NfgWindow { - private _components: NfgComponent[] = []; - private _render: GraphicsRender; - private _uniformTimeout: boolean = false; - private _uniformNeed: boolean = false; - - constructor(render: GraphicsRender) { - this._render = render; - - window.addEventListener("resize", () => { - this._updateWindowSize(); - }); - this._updateWindowSize(); - } - - get width(): number { - return this._render.canvas.width; - } - - get height(): number { - return this._render.canvas.height; - } - - public draw(component: NfgComponent) { - this._components.push(component); - } - - public render(): void { - if (this._uniformNeed) { - this.updateAllUniforms(); - this._uniformNeed = false; - } - this._render.render(this._components); - this._components = []; - } - - private _updateWindowSize(): void { - this._render.canvas.width = window.innerWidth; - this._render.canvas.height = window.innerHeight; - // Uncomment if need performances - // if (this._uniformTimeout) return; - this._uniformTimeout = true; - this._uniformNeed = true; - setTimeout(() => { - this._uniformTimeout = false; - }, 100); - } - - private updateAllUniforms(): void { - this._components.forEach((component) => component.updateUniforms()); - } -} diff --git a/packages/graphics-2d/src/shader/shader.manager.ts b/packages/graphics-2d/src/shader/shader.manager.ts deleted file mode 100644 index 728b76b..0000000 --- a/packages/graphics-2d/src/shader/shader.manager.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { type AssetManagerLibrary } from "@nanoforge/asset-manager"; - -import { type GraphicsCore } from "../core"; -import { SHADER_NAMES, SHADER_PATHS } from "./shaders.const"; -import { type ShadersEnum } from "./shaders.enum"; - -export class ShaderManager { - private _core: GraphicsCore; - private _assetManager: AssetManagerLibrary; - private _shaders: Map; - - constructor(core: GraphicsCore) { - this._core = core; - this._assetManager = - this._core.initContext.libraries.getAssetManager().library; - this._shaders = new Map(); - } - - /** - * @todo Error handling - */ - public async get(shader: ShadersEnum, reftech = true): Promise { - const res = this._shaders.get(shader); - if (!res) { - if (!reftech) throw new Error("Could not find shader"); - await this._loadShader(shader); - return this.get(shader, false); - } - return res; - } - - /** - * @todo Error handling - */ - private async _loadShader(shader: ShadersEnum): Promise { - const path = SHADER_PATHS[shader]; - if (!path) { - throw new Error("Could not find shader"); - } - const shaderFile = await this._assetManager.getWgsl(path); - this._shaders.set( - shader, - this._core.device.createShaderModule({ - label: SHADER_NAMES[shader], - code: await shaderFile.getText(), - }), - ); - } -} diff --git a/packages/graphics-2d/src/shader/shaders.const.ts b/packages/graphics-2d/src/shader/shaders.const.ts deleted file mode 100644 index 28a40b9..0000000 --- a/packages/graphics-2d/src/shader/shaders.const.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ShadersEnum } from "./shaders.enum"; - -export const SHADER_PATHS: Record = { - [ShadersEnum.RECTANGLE]: "rectangle.wgsl", - [ShadersEnum.CIRCLE]: "circle.wgsl", -}; - -export const SHADER_NAMES: Record = { - [ShadersEnum.RECTANGLE]: "Rectangle shader", - [ShadersEnum.CIRCLE]: "Circle shader", -}; diff --git a/packages/graphics-2d/src/shader/shaders.enum.ts b/packages/graphics-2d/src/shader/shaders.enum.ts deleted file mode 100644 index d65b22f..0000000 --- a/packages/graphics-2d/src/shader/shaders.enum.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum ShadersEnum { - RECTANGLE = 0, - CIRCLE = 1, -} diff --git a/packages/graphics-2d/src/shader/shaders/circle.wgsl b/packages/graphics-2d/src/shader/shaders/circle.wgsl deleted file mode 100644 index 72061be..0000000 --- a/packages/graphics-2d/src/shader/shaders/circle.wgsl +++ /dev/null @@ -1,74 +0,0 @@ -var VERTICES: array, 3> = array, 3>( - vec2(-1.7321,-1.0), - vec2( 1.7321,-1.0), - vec2( 0.0 , 2.0), -); - -struct View { - position: vec4, - scale: vec2, - size: vec2, -}; - -@group(0) -@binding(0) -var view: View; - -struct VertexInput { - @builtin(vertex_index) index: u32 -}; - -struct InstanceInput { - @location(0) position: vec2, - @location(1) radius: f32, - @location(2) color: vec4, -}; - -struct VertexOutput { - @builtin(position) clip_space: vec4, - @location(0) local_space: vec2, - @location(1) color: vec4, - @location(2) pixel_size: f32, -}; - -@vertex -fn vertex_main( - vertex: VertexInput, - instance: InstanceInput, -) -> VertexOutput { - var out: VertexOutput; - - let x = view.size.x; - let y = view.size.y; - let aspect = y / x; - - let local_space = VERTICES[vertex.index]; - - var position = instance.position; - var radius = instance.radius; - if radius * y < 1.414214 * view.scale.x { - let a = (position - view.position.xy) / view.scale.x; - let b = (floor(a * y) + 0.5) / y; - let c = b * view.scale.x + view.position.xy; - position = c; - radius = 1.414214 * view.scale.x / y; - } - - let world_space = local_space * radius + position; - - let view_space = (world_space - view.position.xy) / view.scale.x; - - let clip_space = vec4(view_space.x * aspect, view_space.y, 0.0, 1.0); - - out.clip_space = clip_space; - out.local_space = local_space; - out.color = vec4(pow(instance.color.rgb, vec3(2.2)), instance.color.a); - out.pixel_size = view.scale.x / (radius * y); - return out; -} - -@fragment -fn fragment_main(in: VertexOutput) -> @location(0) vec4 { - let alpha = 1.0 - smoothstep(1.0 - 3.0 * in.pixel_size, 1.0, length(in.local_space)); - return vec4(in.color.rgb, in.color.a * alpha); -} diff --git a/packages/graphics-2d/src/shader/shaders/index.ts b/packages/graphics-2d/src/shader/shaders/index.ts deleted file mode 100644 index d361846..0000000 --- a/packages/graphics-2d/src/shader/shaders/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import "./circle.wgsl"; -import "./rectangle.wgsl"; diff --git a/packages/graphics-2d/src/shader/shaders/rectangle.wgsl b/packages/graphics-2d/src/shader/shaders/rectangle.wgsl deleted file mode 100644 index 7838ee6..0000000 --- a/packages/graphics-2d/src/shader/shaders/rectangle.wgsl +++ /dev/null @@ -1,54 +0,0 @@ -struct View { - position: vec4, - scale: vec2, - size: vec2, -}; - -@group(0) -@binding(0) -var view: View; - -struct VertexInput { - @builtin(vertex_index) index: u32 -}; - -struct InstanceInput { - @location(0) min: vec2, - @location(1) max: vec2, - @location(2) color: vec4, -}; - -struct VertexOutput { - @builtin(position) clip_space: vec4, - @location(0) color: vec4, -}; - -@vertex -fn vertex_main( - vertex: VertexInput, - instance: InstanceInput, -) -> VertexOutput { - var result: VertexOutput; - - let x = view.size.x; - let y = view.size.y; - let aspect = y / x; - - var local_space = vec2(f32(vertex.index & 1u), f32(vertex.index >> 1u)); - if vertex.index >= 3 { - local_space = vec2(f32(vertex.index & 1u), f32((vertex.index >> 1u) - 1u)); - } - let position = instance.min + local_space * (instance.max - instance.min); - - let view_space = (position - view.position.xy) / view.scale.x; - let clip_space = vec4(view_space.x * aspect, view_space.y, 0.0, 1.0); - - result.clip_space = clip_space; - result.color = instance.color; - return result; -} - -@fragment -fn fragment_main(vertex: VertexOutput) -> @location(0) vec4 { - return vertex.color; -} diff --git a/packages/graphics-2d/src/types/common/color.type.ts b/packages/graphics-2d/src/types/common/color.type.ts deleted file mode 100644 index a5bc4c5..0000000 --- a/packages/graphics-2d/src/types/common/color.type.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface IColor { - r: number; - g: number; - b: number; - a: number; -} diff --git a/packages/graphics-2d/src/types/common/index.ts b/packages/graphics-2d/src/types/common/index.ts deleted file mode 100644 index 84737ae..0000000 --- a/packages/graphics-2d/src/types/common/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { IColor } from "./color.type"; -export { ISize } from "./size.type"; -export { IVertex2D } from "./vertex-2d.type"; -export { IVertex4D } from "./vertex-4d.type"; diff --git a/packages/graphics-2d/src/types/common/size.type.ts b/packages/graphics-2d/src/types/common/size.type.ts deleted file mode 100644 index 8264d49..0000000 --- a/packages/graphics-2d/src/types/common/size.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ISize { - height: number; - width: number; -} diff --git a/packages/graphics-2d/src/types/common/vertex-2d.type.ts b/packages/graphics-2d/src/types/common/vertex-2d.type.ts deleted file mode 100644 index 4f4cc74..0000000 --- a/packages/graphics-2d/src/types/common/vertex-2d.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IVertex2D { - x: number; - y: number; -} diff --git a/packages/graphics-2d/src/types/common/vertex-4d.type.ts b/packages/graphics-2d/src/types/common/vertex-4d.type.ts deleted file mode 100644 index c24bf2d..0000000 --- a/packages/graphics-2d/src/types/common/vertex-4d.type.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface IVertex4D { - x: number; - y: number; - z: number; - w: number; -} diff --git a/packages/graphics-2d/src/types/index.ts b/packages/graphics-2d/src/types/index.ts deleted file mode 100644 index 3f4c0d3..0000000 --- a/packages/graphics-2d/src/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./common"; -export * from "./options"; diff --git a/packages/graphics-2d/src/types/options/base/color.type.ts b/packages/graphics-2d/src/types/options/base/color.type.ts deleted file mode 100644 index 33a3773..0000000 --- a/packages/graphics-2d/src/types/options/base/color.type.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { type IColor } from "../../common"; - -export interface IColorOption { - color: IColor; -} diff --git a/packages/graphics-2d/src/types/options/base/position.type.ts b/packages/graphics-2d/src/types/options/base/position.type.ts deleted file mode 100644 index b46070f..0000000 --- a/packages/graphics-2d/src/types/options/base/position.type.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { type IVertex2D } from "../../common"; - -export interface IPositionOption { - pos: IVertex2D; -} diff --git a/packages/graphics-2d/src/types/options/base/size.type.ts b/packages/graphics-2d/src/types/options/base/size.type.ts deleted file mode 100644 index a455eb8..0000000 --- a/packages/graphics-2d/src/types/options/base/size.type.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { type ISize } from "../../common"; - -export interface ISizeOption { - size: ISize; -} diff --git a/packages/graphics-2d/src/types/options/final/circle-options.type.ts b/packages/graphics-2d/src/types/options/final/circle-options.type.ts deleted file mode 100644 index c0af50c..0000000 --- a/packages/graphics-2d/src/types/options/final/circle-options.type.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { type IColorOption } from "../base/color.type"; -import { type IPositionOption } from "../base/position.type"; - -export interface ICircleOptions extends IColorOption, IPositionOption { - radius: number; -} diff --git a/packages/graphics-2d/src/types/options/final/index.ts b/packages/graphics-2d/src/types/options/final/index.ts deleted file mode 100644 index d9c15e8..0000000 --- a/packages/graphics-2d/src/types/options/final/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { ICircleOptions } from "./circle-options.type"; -export { IRectangleOptions } from "./rectangle-options.type"; -export { IRoundedRectangleOptions } from "./rounded-rectangle-options.type"; diff --git a/packages/graphics-2d/src/types/options/final/rectangle-options.type.ts b/packages/graphics-2d/src/types/options/final/rectangle-options.type.ts deleted file mode 100644 index 1040464..0000000 --- a/packages/graphics-2d/src/types/options/final/rectangle-options.type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { type IVertex2D } from "../../common"; -import { type IColorOption } from "../base/color.type"; - -export interface IRectangleOptions extends IColorOption { - min: IVertex2D; - max: IVertex2D; -} diff --git a/packages/graphics-2d/src/types/options/final/rounded-rectangle-options.type.ts b/packages/graphics-2d/src/types/options/final/rounded-rectangle-options.type.ts deleted file mode 100644 index 8ab9981..0000000 --- a/packages/graphics-2d/src/types/options/final/rounded-rectangle-options.type.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { type IRectangleOptions } from "./rectangle-options.type"; - -export interface IRoundedRectangleOptions extends IRectangleOptions { - round: number; -} diff --git a/packages/graphics-2d/src/types/options/index.ts b/packages/graphics-2d/src/types/options/index.ts deleted file mode 100644 index c320d6b..0000000 --- a/packages/graphics-2d/src/types/options/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./final"; diff --git a/packages/graphics-2d/src/utils/string.ts b/packages/graphics-2d/src/utils/string.ts deleted file mode 100644 index 9d539ad..0000000 --- a/packages/graphics-2d/src/utils/string.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const formatUpperToLisible = (value: string) => { - return capitalize(value.toLowerCase().replace("_", " ")); -}; - -export const capitalize = (value: string) => { - return value.charAt(0).toUpperCase() + value.slice(1); -}; diff --git a/packages/graphics-2d/tsconfig.build.json b/packages/graphics-2d/tsconfig.build.json index 610404e..49f1428 100644 --- a/packages/graphics-2d/tsconfig.build.json +++ b/packages/graphics-2d/tsconfig.build.json @@ -5,17 +5,13 @@ "outDir": ".", "rootDir": ".", "paths": { - "@nanoforge/common": ["../common"], - "@nanoforge/asset-manager": ["../asset-manager"] + "@nanoforge/common": ["../common"] } }, "exclude": ["node_modules", "dist", "test/**/*", "*.spec.ts"], "references": [ { "path": "../common/tsconfig.build.json" - }, - { - "path": "../asset-manager/tsconfig.build.json" } ] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cabd935..8963ac0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -178,6 +178,9 @@ importers: '@nanoforge/common': specifier: workspace:^ version: link:../common + konva: + specifier: ^10.0.2 + version: 10.0.2 devDependencies: '@nanoforge/utils-eslint-config': specifier: workspace:^ @@ -2764,6 +2767,9 @@ packages: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} + konva@10.0.2: + resolution: {integrity: sha512-NrZED6YG5BX5h3Xu8EZgLqhQ/+ZhxANYXmlIhMOfpBf+0ToExcdwE+Y46LyJOO/JR7FVeR3YTqon3eirnuo44A==} + lerna@8.2.4: resolution: {integrity: sha512-0gaVWDIVT7fLfprfwpYcQajb7dBJv3EGavjG7zvJ+TmGx3/wovl5GklnSwM2/WeE0Z2wrIz7ndWhBcDUHVjOcQ==} engines: {node: '>=18.0.0'} @@ -7038,6 +7044,8 @@ snapshots: kind-of@6.0.3: {} + konva@10.0.2: {} + lerna@8.2.4(@types/node@22.18.7)(encoding@0.1.13): dependencies: '@lerna/create': 8.2.4(@types/node@22.18.7)(encoding@0.1.13)(typescript@5.9.2)