Skip to content

Commit

Permalink
Started work on Drawing-Shape and Tile-Mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
JPMeehan committed Dec 15, 2023
1 parent 7f1d12c commit 3216b27
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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) {

Check failure on line 7 in src/foundry/client/pixi/placeables/primary-canvas-objects/drawing-shape.d.ts

View workflow job for this annotation

GitHub Actions / type check code base

Class static side 'typeof DrawingShape' incorrectly extends base class static side 'Pick<typeof Graphics, "prototype" | "defaultSortableChildren" | "mixin" | "prefixed" | "EventEmitter" | "curves" | "_TEMP_POINT"> & typeof PrimaryCanvasObject'.

Check failure on line 7 in src/foundry/client/pixi/placeables/primary-canvas-objects/drawing-shape.d.ts

View workflow job for this annotation

GitHub Actions / type check code base

Base constructors must all have the same return type.
/**
* 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;
};
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { DisplayObject } from "pixi.js";

export {};

type ClientDocument = unknown;
Expand Down Expand Up @@ -139,7 +141,10 @@ declare global {
* @param DisplayObject - The parent DisplayObject class being mixed
* @returns A DisplayObject subclass mixed with PrimaryCanvasObject features
*/
function PrimaryCanvasObjectMixin<BaseClass extends typeof PIXI.DisplayObject>(
function PrimaryCanvasObjectMixin<
BaseClass extends Pick<typeof PIXI.DisplayObject, keyof typeof PIXI.DisplayObject> &
(new (...args: any[]) => PIXI.DisplayObject),
>(
DisplayObject: BaseClass,
): Pick<BaseClass, keyof BaseClass> &
typeof PrimaryCanvasObject & {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Check failure on line 8 in src/foundry/client/pixi/placeables/primary-canvas-objects/tile-mesh.d.ts

View workflow job for this annotation

GitHub Actions / type check code base

This member cannot have an 'override' modifier because it is not declared in the base class 'OccludableObject & SpriteMesh'.

override setPosition(x: number, y: number): void;

Check failure on line 10 in src/foundry/client/pixi/placeables/primary-canvas-objects/tile-mesh.d.ts

View workflow job for this annotation

GitHub Actions / type check code base

This member cannot have an 'override' modifier because it is not declared in the base class 'OccludableObject & SpriteMesh'. Did you mean 'position'?

override updateBounds(): void;

Check failure on line 12 in src/foundry/client/pixi/placeables/primary-canvas-objects/tile-mesh.d.ts

View workflow job for this annotation

GitHub Actions / type check code base

This member cannot have an 'override' modifier because it is not declared in the base class 'OccludableObject & SpriteMesh'.
}
}

0 comments on commit 3216b27

Please sign in to comment.