From 06dc5d2d99c1d2e5cc03b257325849e9afe10555 Mon Sep 17 00:00:00 2001 From: pasting Date: Sat, 23 Dec 2023 15:39:26 -0800 Subject: [PATCH 1/3] partially updated gfx --- AutoComplete/library/gfx.d.ts | 98 ++++++++++++++++++++++++++++++----- README.md | 4 ++ 2 files changed, 90 insertions(+), 12 deletions(-) diff --git a/AutoComplete/library/gfx.d.ts b/AutoComplete/library/gfx.d.ts index cb80d8a..024dee6 100644 --- a/AutoComplete/library/gfx.d.ts +++ b/AutoComplete/library/gfx.d.ts @@ -6,8 +6,10 @@ declare namespace gfx { * @param {number} r red * @param {number} g green * @param {number} b blue + * @param {number?} a opacity + */ - function color(r: number, g: number, b: number): void; + function color(r: number, g: number, b: number, a?: number): void; /** * Sets the texture drawing color, values range from 0 to 255 @@ -15,8 +17,9 @@ declare namespace gfx { * @param {number} r red * @param {number} g green * @param {number} b blue + * @param {number?} a opacity */ - function tcolor(r: number, g: number, b: number): void; + function tcolor(r: number, g: number, b: number, a?: number): void; /** * Sets if the 3D rendering should render trough blocks @@ -25,20 +28,30 @@ declare namespace gfx { function renderBehind(phaseTroughBlocks: boolean): void; /** - * Sets the drawing color, values range from 0 to 255 - * Gfx drawing functions will use this color - * @param {number} r red - * @param {number} g green - * @param {number} b blue - * @param {number} a Opacity + * The render origin (the player's eyes for first person) + * @returns {LuaMultiReturn<[number, number, number]>} x, y, z */ - function color(r: number, g: number, b: number, a: number): void; + function origin(): LuaMultiReturn<[number, number, number]>; /** - * The render origin (the player's eyes for first person) - * @returns {LuaMultiReturn<[number, number, number]>} + * Gets screen position from world position + * Getting nil means that the position is not on screen + * @param {number} x The world position X + * @param {number} y The world position Y + * @param {number} z The world position Z + * @returns {LuaMultiReturn<[number|null, number|null]>} The screen position X, The screen position Y */ - function origin(): LuaMultiReturn<[number, number, number]>; + function worldToScreen(x: number, y: number, z: number): LuaMultiReturn<[number|null, number|null]> + + + /** + * Gets screen position from world position and gives you a table of number with a size of 2 + * @param {number} x The world position X + * @param {number} y The world position Y + * @param {number} z The world position Z + * @return {number[]|null} x The screen position X + */ +function worldToScreen2(x: number, y: number, z: number): number[]|null /** * Renders a rectangle @@ -501,6 +514,65 @@ declare namespace gfx { bothSides?: boolean ): void; + /** + * Renders a lot of textured quads + * This allows it to do it much quicker as it batches it instead of having one draw call per texture quad like tquad + * You can use parts of a texture with uv to have more textures in one draw + * You should sort the quads by color and texture to call this function less times, but with as much data as possible each time. + * quads is a table of table containing 20 numbers + * you have 4 corners, each corner has 5 numbers (x, y, z, uvx, uvy) + * exemple order: top left, bottom left, bottom right, top right + * @param {number[][]} quads The quads to render + * @param {string} texturePath the texture file (starting with "textures" will be taken from the resource pack otherwise data folder) + * @param {boolean|null} bothSides Should render both sides (would be visible from only one side if set to false/nil) + */ + function tquadbatch(quads: number[][], texturePath: string, bothSides: boolean|null): void + + /** + * Changes the lighting parameters for future gfx calls (3d only) + * @param {number} AreaStartX The starting X position of the area + * @param {number} AreaStartY The starting Y position of the area + * @param {number} AreaStartZ The starting Z position of the area + * @param {number} AreaEndX The ending X position of the area + * @param {number} AreaEndY The ending Y position of the area + * @param {number} AreaEndZ The ending Z position of the area + * @param {number?} minimumBrightness The minimum brightness (Must be an integer) + */ + function setupLights( + AreaStartX: number, + AreaStartY: number, + AreaStartZ: number, + AreaEndX: number, + AreaEndY: number, + AreaEndZ: number, + minimumBrightness?: number): void + + /** + * Changes the lighting parameters for future gfx calls (3d only) + * @param {number} AreaStartX The starting X position of the area + * @param {number} AreaStartY The starting Y position of the area + * @param {number} AreaStartZ The starting Z position of the area + * @param {number} AreaEndX The ending X position of the area + * @param {number} AreaEndY The ending Y position of the area + * @param {number} AreaEndZ The ending Z position of the area + * @param {number} CenterX The center X of the area, you can uncenter it if it gives an effect you prefer + * @param {number} CenterY The center Y of the area, you can uncenter it if it gives an effect you prefer + * @param {number} CenterZ The center Z of the area, you can uncenter it if it gives an effect you prefer + * @param {number?} minimumBrightness The minimum brightness (Must be an integer) + */ + function setupLights( + AreaStartX: number, + AreaStartY: number, + AreaStartZ: number, + AreaEndX: number, + AreaEndY: number, + AreaEndZ: number, + CenterX: number, + CenterY: number, + CenterZ: number, + minimumBrightness?: number): void + + /** * @param {string} content Filepath to the .obj file * @param {boolean?} isFilepath use 'content' as filepath or obj file content @@ -515,6 +587,8 @@ declare namespace gfx { */ function objRender(mesh: any, texture?: string): void; + + /** * Pushes transformation(s) * @param transformations diff --git a/README.md b/README.md index 7afac30..32d57b1 100644 --- a/README.md +++ b/README.md @@ -66,3 +66,7 @@ We have some improvements planned for this repository: - Improve the type definitions for built-in functions, and make them easier to maintain and update. - Simplify the setup process for an easier installation experience. + +In gfx: + +- Translate geometryLoad, geometryRender \ No newline at end of file From d793b8aecbad1c95d227d5697fc1ea6d573be3b0 Mon Sep 17 00:00:00 2001 From: pasting Date: Sat, 23 Dec 2023 16:25:38 -0800 Subject: [PATCH 2/3] gfx2 updated --- AutoComplete/library/gfx2.d.ts | 49 ++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/AutoComplete/library/gfx2.d.ts b/AutoComplete/library/gfx2.d.ts index cb9fa71..ea798d3 100644 --- a/AutoComplete/library/gfx2.d.ts +++ b/AutoComplete/library/gfx2.d.ts @@ -50,21 +50,10 @@ declare interface Gfx2Texture { * @param {number} r new red color value (0-255) * @param {number} g new green color value (0-255) * @param {number} b new blue color value (0-255) + * @param {number?} a new alpha value (0-255) * @diagnostic disable-next-line: duplicate-set-field */ - setPixel(x: number, y: number, r: number, g: number, b: number): void; - - /** - * Sets the color of a pixel in the texture, you must unload if you used it for changes to apply - * @param {number} x X position of the pixel to get - * @param {number} y Y position of the pixel to get - * @param {number} r new red color value (0-255) - * @param {number} g new green color value (0-255) - * @param {number} b new blue color value (0-255) - * @param {number} a new alpha value (0-255) - * @diagnostic disable-next-line: duplicate-set-field - */ - setPixel(x: number, y: number, r: number, g: number, b: number, a: number): void; + setPixel(x: number, y: number, r: number, g: number, b: number, a?: number): void; /** * Saves the texture to a png file (for if you wana draw to it using setPixel) @@ -92,10 +81,25 @@ declare namespace gfx2 { * @param {number} r 0-255 color code * @param {number} g 0-255 color code * @param {number} b 0-255 color code - * @param {number?} a 0-255 color code + * @param {number?} a opacity 0-255 color code */ function color(r: number, g: number, b: number, a?: number): void; + /** + * Changes the tint color of images that will be rendered + * @param setting Setting client color(pls or u crash) setting + */ + function tcolor(setting: ColorSetting | ColorProperties): void; + + /** + * Changes the tint color of images that will be rendered + * @param {number} r 0-255 color code + * @param {number} g 0-255 color code + * @param {number} b 0-255 color code + * @param {number?} a opacity 0-255 color code + */ + function tcolor(r: number, g: number, b: number, a?: number): void; + /** * Gives you the size of the current render target * @returns {number} width @@ -161,6 +165,23 @@ declare namespace gfx2 { */ function drawRoundRect(x: number, y: number, width: number, height: number, radius: number, lineWidth: number): void; + /** + * Fills an elipse (circle but possibly wider) + * @param {number} centerX The X axis center position of the elipse + * @param {number} centerY The Y axis center position of the elipse + * @param {number} radius How big is the circle + */ + function fillElipse(centerX: number, centerY: number, radius: number): void; + + /** + * Fills an elipse (circle but possibly wider) + * @param {number} centerX The X axis center position of the elipse + * @param {number} centerY The Y axis center position of the elipse + * @param {number} radiusX How Wide is the elipse + * @param {number} radiusY how High is the elipse + */ + function fillElipse(centerX: number, centerY: number, radiusX: number, radiusY: number): void; + /** * Draws an elipse (circle but possibly wider) * @param {number} centerX The X axis center position of the elipse From 57a246f5fe4f712488f229b312cbb93aa2cd37d4 Mon Sep 17 00:00:00 2001 From: pasting Date: Sat, 23 Dec 2023 16:55:14 -0800 Subject: [PATCH 3/3] updated fs, reverted readme --- AutoComplete/library/fs.d.ts | 15 +++++++++++++++ README.md | 4 ---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/AutoComplete/library/fs.d.ts b/AutoComplete/library/fs.d.ts index c036964..2bd5322 100644 --- a/AutoComplete/library/fs.d.ts +++ b/AutoComplete/library/fs.d.ts @@ -89,6 +89,21 @@ declare const fs: { * @return {BinaryFile | void} The (hopefully) opened file */ open(path: string, openmode: "w" | "r" | "a"): BinaryFile | void; + + /** + * Opens a file to read/write data that can also be compressed + * If you dont skip the header putting anything that isn't 'store' or 'none' will ignore what you supply and read the header, otherwise it will trust you + * @param {string} path The path from Scripts/Data + * @param {"w" | "r" | "a" | nil} openmode how to open the file, w is write mode, r is read mode, a is append(and it will add to an existing file or start), nil to open a memory stream + * @param {"lzma" | "deflate" | "gzip2" | "store" | "none"} compressionType The compression type to use, anything that isn't store or none will have compression enabled + * @param {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9} compressionLevel The compression level to use, 0 is terrible compression, 1 is fastest, 6 is balanced, 9 is best compression + * @param {boolean} compressionHeader If you want to skip the header, if you do you can't read the file without knowing the compression type + */ + open(path: string, + openmode: "w" | "r" | "a", + compressionType: "lzma" | "deflate" | "gzip2" | "store" | "none", + compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9, + compressionHeader: boolean): void } declare interface Stats { diff --git a/README.md b/README.md index 32d57b1..7afac30 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,3 @@ We have some improvements planned for this repository: - Improve the type definitions for built-in functions, and make them easier to maintain and update. - Simplify the setup process for an easier installation experience. - -In gfx: - -- Translate geometryLoad, geometryRender \ No newline at end of file