From 3216b2769f5421c82aa0fa49193cb4f6c71aab9b Mon Sep 17 00:00:00 2001 From: JPMeehan Date: Fri, 15 Dec 2023 15:09:51 -0800 Subject: [PATCH] Started work on Drawing-Shape and Tile-Mesh --- .../primary-canvas-objects/drawing-shape.d.ts | 143 ++++++++++++++++++ .../primary-canvas-object.d.ts | 7 +- .../primary-canvas-objects/tile-mesh.d.ts | 14 ++ 3 files changed, 163 insertions(+), 1 deletion(-) diff --git a/src/foundry/client/pixi/placeables/primary-canvas-objects/drawing-shape.d.ts b/src/foundry/client/pixi/placeables/primary-canvas-objects/drawing-shape.d.ts index e69de29bb..86d63cd5f 100644 --- a/src/foundry/client/pixi/placeables/primary-canvas-objects/drawing-shape.d.ts +++ b/src/foundry/client/pixi/placeables/primary-canvas-objects/drawing-shape.d.ts @@ -0,0 +1,143 @@ +export {}; + +declare global { + /** + * A special subclass of PIXI.Container used to represent a Drawing in the PrimaryCanvasGroup. + */ + class DrawingShape extends PrimaryCanvasObjectMixin(PIXI.Graphics) { + /** + * Sorting values to deal with ties. + */ + static PRIMARY_SORT_ORDER: number; + + /** + * @defaultValue + * ```js + * return foundry.utils.mergeObject(super.defaultData, { + * shape: { + * type: "", + * width: 0, + * height: 0, + * radius: null, + * points: [] + * }, + * bezierFactor: 0, + * fillType: 0, + * fillColor: 0x7C7C7C, + * fillAlpha: 0.5, + * strokeWidth: 8, + * strokeColor: 0xFFFFFF, + * strokeAlpha: 1, + * text: "New Text", + * fontFamily: "Signika", + * fontSize: 48, + * textColor: 0xFFFFFF, + * textAlpha: 1 + * }) + * ``` + */ + static override get defaultData(): DrawingShape.PrimaryCanvasObjectDrawingShapeData & PrimaryCanvasObject.Data; + + override refresh(): void; + + override setPosition(): void; + + protected override _getCanvasDocumentData(data: Document): unknown; + + /** + * Draw rectangular shapes. + */ + protected _drawRectangle(): void; + + /** + * Draw ellipsoid shapes. + */ + protected _drawEllipse(): void; + + /** + * Draw polygonal shapes. + */ + protected _drawPolygon(): void; + + /** + * Draw freehand shapes with bezier spline smoothing. + */ + protected _drawFreehand(): void; + } + + namespace DrawingShape { + type PrimaryCanvasObjectDrawingShapeData = { + /** The shape */ + shape: object; + + /** The x-coordinate of the PCO location */ + x: number; + + /** The y-coordinate of the PCO location */ + y: number; + + /** The z-index of the PCO */ + z: number; + + /** The bezier factor */ + bezierFactor: number; + + /** The fill type */ + fillType: number; + + /** The fill color */ + fillColor: number; + + /** The fill alpha */ + fillAlpha: number; + + /** The stroke width */ + strokeWidth: number; + + /** The stroke color */ + strokeColor: number; + + /** The stroke alpha */ + strokeAlpha: number; + + /** The text */ + text: string; + + /** The text font family */ + fontFamily: string; + + /** The font size */ + fontSize: number; + + /** The text color */ + textColor: number; + + /** The text alpha */ + textAlpha: number; + + /** The rotation of this PCO */ + rotation: number; + + /** The PCO is hidden? */ + hidden: boolean; + + /** The elevation of the PCO */ + elevation: number; + + /** The sort key that resolves ties among the same elevation */ + sort: number; + + /** The PCO is considered as a roof? */ + roof: boolean; + + /** The PCO is considered as overhead? */ + overhead: boolean; + + /** The occlusion object for this PCO */ + occlusion: object; + + /** The data texture values */ + texture: object; + }; + } +} diff --git a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.ts b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.ts index 4f5954ca8..cbe88324e 100644 --- a/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.ts +++ b/src/foundry/client/pixi/placeables/primary-canvas-objects/primary-canvas-object.d.ts @@ -1,3 +1,5 @@ +import type { DisplayObject } from "pixi.js"; + export {}; type ClientDocument = unknown; @@ -139,7 +141,10 @@ declare global { * @param DisplayObject - The parent DisplayObject class being mixed * @returns A DisplayObject subclass mixed with PrimaryCanvasObject features */ - function PrimaryCanvasObjectMixin( + function PrimaryCanvasObjectMixin< + BaseClass extends Pick & + (new (...args: any[]) => PIXI.DisplayObject), + >( DisplayObject: BaseClass, ): Pick & typeof PrimaryCanvasObject & { diff --git a/src/foundry/client/pixi/placeables/primary-canvas-objects/tile-mesh.d.ts b/src/foundry/client/pixi/placeables/primary-canvas-objects/tile-mesh.d.ts index e69de29bb..7d9cad09d 100644 --- a/src/foundry/client/pixi/placeables/primary-canvas-objects/tile-mesh.d.ts +++ b/src/foundry/client/pixi/placeables/primary-canvas-objects/tile-mesh.d.ts @@ -0,0 +1,14 @@ +export {}; + +declare global { + /** + * A SpriteMesh which visualizes a Tile object in the PrimaryCanvasGroup. + */ + class TileMesh extends OccludableObjectMixin(SpriteMesh) { + override refresh(): void; + + override setPosition(x: number, y: number): void; + + override updateBounds(): void; + } +}