From 81ef029bf6d52b3367f6e444f1b1a55144f3ad7f Mon Sep 17 00:00:00 2001 From: split / May Date: Wed, 1 Jan 2025 05:21:29 -0800 Subject: [PATCH] docs: :memo: add TSDoc comments to functions in the DDS class --- AquaNet/src/libs/userbox/dds.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/AquaNet/src/libs/userbox/dds.ts b/AquaNet/src/libs/userbox/dds.ts index 56180c8c..4da5fe28 100644 --- a/AquaNet/src/libs/userbox/dds.ts +++ b/AquaNet/src/libs/userbox/dds.ts @@ -193,6 +193,11 @@ export class DDS { } }; + /** + * @description Retrieve a file from the IndexedDB database and load it into the DDS loader + * @param path File path + * @returns Whether or not the attempt to retrieve the file was successful + */ loadFile(path: string) : Promise { return new Promise(async r => { if (!this.db) @@ -212,6 +217,12 @@ export class DDS { }) }; + /** + * @description Retrieve a file from a path + * @param path File path + * @param fallback Path to a file to fallback to if loading this file fails + * @returns An object URL which correlates to a Blob + */ async getFile(path: string, fallback?: string) : Promise { if (this.urlCache[path]) return this.urlCache[path] @@ -226,6 +237,16 @@ export class DDS { return url }; + /** + * @description Transform a spritesheet located at a path to match the dimensions specified in the parameters + * @param path Spritesheet path + * @param x Crop: X + * @param y Crop: Y + * @param w Crop: Width + * @param h Crop: Height + * @param s Scale factor + * @returns An object URL which correlates to a Blob + */ async getFileFromSheet(path: string, x: number, y: number, w: number, h: number, s?: number): Promise { if (!await this.loadFile(path)) return ""; @@ -236,6 +257,13 @@ export class DDS { return URL.createObjectURL(await this.get2DBlob("image/png") ?? new Blob([])); }; + /** + * @description Retrieve a file and scale it by a specified scale factor + * @param path File path + * @param s Scale factor + * @param fallback Path to a file to fallback to if loading this file fails + * @returns An object URL which correlates to a Blob + */ async getFileScaled(path: string, s: number, fallback?: string): Promise { if (this.urlCache[path]) return this.urlCache[path]