diff --git a/CMakeLists.txt b/CMakeLists.txt index 4be68b9..6d4ddd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,4 +37,6 @@ file(GLOB files src/*.c) add_executable(${CMAKE_PROJECT_NAME} ${files}) target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE include) target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE src) +target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE thirdparty/raylib/examples/shapes) +target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE thirdparty/raylib/examples/shaders) target_link_libraries(${CMAKE_PROJECT_NAME} quickjs raylib) \ No newline at end of file diff --git a/bindings/src/header-parser.ts b/bindings/src/header-parser.ts index 17d7e9b..5a406b9 100644 --- a/bindings/src/header-parser.ts +++ b/bindings/src/header-parser.ts @@ -33,7 +33,7 @@ export class HeaderParser { return input.split('\n').map(x => x.replace("// ","")).join('\n').trim() } parseFunctionDefinitions(input: string): RayLibFunction[] { - const matches = [...input.matchAll(/^[A-Z]+API (.+?)(\w+)\(([^\)]+)\);(?:[^\/]+\/\/ (.+))?/gm)] + const matches = [...input.matchAll(/^[A-Z]+ (.+?)(\w+)\(([^\)]+)\);(?: +\/\/ (.+))?$/gm)] return matches.map(groups => ({ returnType: groups![1].trim(), name: groups![2], @@ -41,14 +41,15 @@ export class HeaderParser { description: groups![4] || "" })) } - parseFunctions(input: string): RayLibFunction[] { - const matches = [...input.matchAll(/((?:\/\/ .+\n)*)[A-Z]+API\s+([\w<>]+)\s+([\w<>]+)\((.*)\)/gm)] - console.log(matches[0]) + parseFunctions(input: string, noPrefix: boolean = false): RayLibFunction[] { + const matches = noPrefix + ? [...input.matchAll(/((?:\/\/.+\n)+)^(.+?)(\w+)\(([^\)]+)\)/gm)] + : [...input.matchAll(/((?:\/\/.+\n)+)^[A-Z]+ (.+?)(\w+)\(([^\)]+)\)/gm)] return matches.map(groups => ({ - returnType: groups![1].trim(), - name: groups![2], - params: this.parseFunctionArgs(groups![3]), - description: groups![4] || "" + returnType: groups![2].trim(), + name: groups![3], + params: this.parseFunctionArgs(groups![4]), + description: groups![1] ? this.parseComments(groups![1]) : "" })) } parseFunctionArgs(input: string): RayLibParamDescription[] { diff --git a/bindings/src/index.ts b/bindings/src/index.ts index 3e7a1a6..4bd209e 100644 --- a/bindings/src/index.ts +++ b/bindings/src/index.ts @@ -4,30 +4,6 @@ import { ApiDescription, ApiFunction } from "./api"; import { RayLibHeader } from "./raylib-header"; import { HeaderParser } from "./header-parser"; -function parseHeader(path: string, prefix: string): RayLibFunction[] { - const i = readFileSync(path, 'utf8') - const regex = new RegExp(`((?:\\/\\/ .+\\n)*)${prefix}\\s+([\\w<>]+)\\s+([\\w<>]+)\\((.*)\\)`, 'gm') - const m = [...i.matchAll(regex)] - const res = m.map(groups => { - const args = groups[4].split(',').filter(x => x !== 'void').map(arg => { - arg = arg.trim().replace(" *", "* ") - const frags = arg.split(' ') - const name = frags.pop() - const type = frags.join(' ').replace("*", " *") - - return { name: name || "", type: type } - }) - const comments = groups[1].split('\n').map(x => x.replace("// ","")).join('\n').trim() - return { - name: groups[3], - returnType: groups[2], - params: args, - description: comments - } - }) - return res; -} - function main(){ // Load the pre-generated raylib api @@ -40,25 +16,42 @@ function main(){ params: [{type: "Model *",name:"model"},{type:"int",name:"materialIndex"},{type:"Material",name:"material"}] }) - const rguiHeader = readFileSync("thirdparty/raylib/examples/shapes/raygui.h","utf8"); const parser = new HeaderParser() - //writeFileSync("enums.json",JSON.stringify(parser.parseEnums(rayguiHeader))) - //writeFileSync("functions.json",JSON.stringify(parser.parseFunctions(rayguiHeader))) - + const rmathHeader = readFileSync("thirdparty/raylib/src/raymath.h","utf8"); - const mathApi = parseHeader("thirdparty/raylib/src/raymath.h", "RMAPI"); + const mathApi = parser.parseFunctions(rmathHeader) mathApi.forEach(x => api.functions.push(x)) const rcameraHeader = readFileSync("thirdparty/raylib/src/rcamera.h","utf8"); - const cameraApi = parseHeader("thirdparty/raylib/src/rcamera.h", "RLAPI"); - //cameraApi.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) + const cameraApi = parser.parseFunctionDefinitions(rcameraHeader); cameraApi.forEach(x => api.functions.push(x)) + + const rguiHeader = readFileSync("thirdparty/raylib/examples/shapes/raygui.h","utf8"); + const rguiFunctions = parser.parseFunctionDefinitions(rguiHeader); + const rguiEnums = parser.parseFunctionDefinitions(rguiHeader); + //rguiApi.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) + rguiFunctions.forEach(x => api.functions.push(x)) + + const rlightsHeader = readFileSync("thirdparty/raylib/examples/shaders/rlights.h","utf8"); + const rlightsFunctions = parser.parseFunctions(rlightsHeader, true); + api.functions.push(rlightsFunctions[0]) + api.functions.push(rlightsFunctions[1]) + + const reasingsHeader = readFileSync("thirdparty/raylib/examples/shapes/reasings.h","utf8"); + const reasingsFunctions = parser.parseFunctions(reasingsHeader); + //reasingsFunctions.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) + reasingsFunctions.forEach(x => api.functions.push(x)) const apiDesc = new ApiDescription(api) const core = new RayLibHeader("raylib_core", apiDesc) core.includes.include("raymath.h") core.includes.include("rcamera.h") + core.includes.line("#define RAYGUI_IMPLEMENTATION") + core.includes.include("raygui.h") + core.includes.line("#define RLIGHTS_IMPLEMENTATION") + core.includes.include("rlights.h") + core.includes.include("reasings.h") core.addApiStructByName("Color", { properties: { @@ -1047,6 +1040,92 @@ function main(){ core.addApiFunctionByName("GetCameraViewMatrix") core.addApiFunctionByName("GetCameraProjectionMatrix") + // module: rgui + core.addApiFunctionByName("GuiEnable") + core.addApiFunctionByName("GuiDisable") + core.addApiFunctionByName("GuiLock") + core.addApiFunctionByName("GuiUnlock") + core.addApiFunctionByName("GuiIsLocked") + core.addApiFunctionByName("GuiFade") + core.addApiFunctionByName("GuiSetState") + core.addApiFunctionByName("GuiGetState") + core.addApiFunctionByName("GuiSetFont") + core.addApiFunctionByName("GuiGetFont") + core.addApiFunctionByName("GuiSetStyle") + core.addApiFunctionByName("GuiGetStyle") + core.addApiFunctionByName("GuiWindowBox") + core.addApiFunctionByName("GuiGroupBox") + core.addApiFunctionByName("GuiLine") + core.addApiFunctionByName("GuiPanel") + core.addApiFunctionByName("GuiScrollPanel") + core.addApiFunctionByName("GuiLabel") + core.addApiFunctionByName("GuiButton") + core.addApiFunctionByName("GuiLabelButton") + core.addApiFunctionByName("GuiToggle") + core.addApiFunctionByName("GuiToggleGroup") + core.addApiFunctionByName("GuiCheckBox") + core.addApiFunctionByName("GuiComboBox") + //core.addApiFunctionByName("GuiDropdownBox") + //core.addApiFunctionByName("GuiSpinner") + //core.addApiFunctionByName("GuiValueBox") + core.addApiFunctionByName("GuiTextBox") + core.addApiFunctionByName("GuiTextBoxMulti") + core.addApiFunctionByName("GuiSlider") + core.addApiFunctionByName("GuiSliderBar") + core.addApiFunctionByName("GuiProgressBar") + core.addApiFunctionByName("GuiStatusBar") + core.addApiFunctionByName("GuiDummyRec") + core.addApiFunctionByName("GuiGrid") + //core.addApiFunctionByName("GuiListView") + //core.addApiFunctionByName("GuiListViewEx") + core.addApiFunctionByName("GuiMessageBox") + //core.addApiFunctionByName("GuiTextInputBox") + core.addApiFunctionByName("GuiColorPicker") + core.addApiFunctionByName("GuiColorPanel") + core.addApiFunctionByName("GuiColorBarAlpha") + core.addApiFunctionByName("GuiColorBarHue") + core.addApiFunctionByName("GuiLoadStyle") + core.addApiFunctionByName("GuiLoadStyleDefault") + core.addApiFunctionByName("GuiIconText") + core.addApiFunctionByName("GuiDrawIcon") + //core.addApiFunctionByName("GuiGetIcons") + //core.addApiFunctionByName("GuiGetIconData") + //core.addApiFunctionByName("GuiSetIconData") + core.addApiFunctionByName("GuiSetIconScale") + core.addApiFunctionByName("GuiSetIconPixel") + core.addApiFunctionByName("GuiClearIconPixel") + core.addApiFunctionByName("GuiCheckIconPixel") + + // module: rlights + // TODO: Parse and support light struct + // core.addApiFunctionByName("CreateLight") + // core.addApiFunctionByName("UpdateLightValues") + + // module: reasings + core.addApiFunctionByName("EaseLinearNone") + core.addApiFunctionByName("EaseLinearIn") + core.addApiFunctionByName("EaseLinearOut") + core.addApiFunctionByName("EaseLinearInOut") + core.addApiFunctionByName("EaseSineIn") + core.addApiFunctionByName("EaseSineOut") + core.addApiFunctionByName("EaseSineInOut") + core.addApiFunctionByName("EaseCircIn") + core.addApiFunctionByName("EaseCircOut") + core.addApiFunctionByName("EaseCircInOut") + core.addApiFunctionByName("EaseCubicIn") + core.addApiFunctionByName("EaseCubicOut") + core.addApiFunctionByName("EaseCubicInOut") + core.addApiFunctionByName("EaseQuadIn") + core.addApiFunctionByName("EaseQuadOut") + core.addApiFunctionByName("EaseQuadInOut") + core.addApiFunctionByName("EaseExpoIn") + core.addApiFunctionByName("EaseExpoOut") + core.addApiFunctionByName("EaseExpoInOut") + core.addApiFunctionByName("EaseBackIn") + core.addApiFunctionByName("EaseBounceOut") + core.addApiFunctionByName("EaseBounceInOut") + core.addApiFunctionByName("EaseElasticIn") + api.defines.filter(x => x.type === "COLOR").map(x => ({ name: x.name, description: x.description, values: (x.value.match(/\{([^}]+)\}/) || "")[1].split(',').map(x => x.trim()) })).forEach(x => { core.exportGlobalStruct("Color", x.name, x.values, x.description) }) diff --git a/examples/lib.raylib.d.ts b/examples/lib.raylib.d.ts index 8a342e1..d58642d 100644 --- a/examples/lib.raylib.d.ts +++ b/examples/lib.raylib.d.ts @@ -1366,7 +1366,7 @@ declare function getCameraForward(camera: Camera3D): Vector3; declare function getCameraUp(camera: Camera3D): Vector3; /** */ declare function getCameraRight(camera: Camera3D): Vector3; -/** Camera movement */ +/** */ declare function cameraMoveForward(camera: Camera3D, distance: number, moveInWorldPlane: boolean): void; /** */ declare function cameraMoveUp(camera: Camera3D, distance: number): void; @@ -1374,7 +1374,7 @@ declare function cameraMoveUp(camera: Camera3D, distance: number): void; declare function cameraMoveRight(camera: Camera3D, distance: number, moveInWorldPlane: boolean): void; /** */ declare function cameraMoveToTarget(camera: Camera3D, delta: number): void; -/** Camera rotation */ +/** */ declare function cameraYaw(camera: Camera3D, angle: number, rotateAroundTarget: boolean): void; /** */ declare function cameraPitch(camera: Camera3D, angle: number, lockView: boolean, rotateAroundTarget: boolean, rotateUp: boolean): void; @@ -1384,6 +1384,142 @@ declare function cameraRoll(camera: Camera3D, angle: number): void; declare function getCameraViewMatrix(camera: Camera3D): Matrix; /** */ declare function getCameraProjectionMatrix(camera: Camera3D, aspect: number): Matrix; +/** Enable gui controls (global state) */ +declare function guiEnable(): void; +/** Disable gui controls (global state) */ +declare function guiDisable(): void; +/** Lock gui controls (global state) */ +declare function guiLock(): void; +/** Unlock gui controls (global state) */ +declare function guiUnlock(): void; +/** Check if gui is locked (global state) */ +declare function guiIsLocked(): boolean; +/** Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f */ +declare function guiFade(alpha: number): void; +/** Set gui state (global state) */ +declare function guiSetState(state: number): void; +/** Get gui state (global state) */ +declare function guiGetState(): number; +/** Set gui custom font (global state) */ +declare function guiSetFont(font: Font): void; +/** Get gui custom font (global state) */ +declare function guiGetFont(): Font; +/** Set one style property */ +declare function guiSetStyle(control: number, property: number, value: number): void; +/** Get one style property */ +declare function guiGetStyle(control: number, property: number): number; +/** Window Box control, shows a window that can be closed */ +declare function guiWindowBox(bounds: Rectangle, title: string): boolean; +/** Group Box control with text name */ +declare function guiGroupBox(bounds: Rectangle, text: string): void; +/** Line separator control, could contain text */ +declare function guiLine(bounds: Rectangle, text: string): void; +/** Panel control, useful to group controls */ +declare function guiPanel(bounds: Rectangle, text: string): void; +/** Scroll Panel control */ +declare function guiScrollPanel(bounds: Rectangle, text: string, content: Rectangle, scroll: Vector2): Rectangle; +/** Label control, shows text */ +declare function guiLabel(bounds: Rectangle, text: string): void; +/** Button control, returns true when clicked */ +declare function guiButton(bounds: Rectangle, text: string): boolean; +/** Label button control, show true when clicked */ +declare function guiLabelButton(bounds: Rectangle, text: string): boolean; +/** Toggle Button control, returns true when active */ +declare function guiToggle(bounds: Rectangle, text: string, active: boolean): boolean; +/** Toggle Group control, returns active toggle index */ +declare function guiToggleGroup(bounds: Rectangle, text: string, active: number): number; +/** Check Box control, returns true when active */ +declare function guiCheckBox(bounds: Rectangle, text: string, checked: boolean): boolean; +/** Combo Box control, returns selected item index */ +declare function guiComboBox(bounds: Rectangle, text: string, active: number): number; +/** Text Box control, updates input text */ +declare function guiTextBox(bounds: Rectangle, text: string, textSize: number, editMode: boolean): boolean; +/** Text Box control with multiple lines */ +declare function guiTextBoxMulti(bounds: Rectangle, text: string, textSize: number, editMode: boolean): boolean; +/** Slider control, returns selected value */ +declare function guiSlider(bounds: Rectangle, textLeft: string, textRight: string, value: number, minValue: number, maxValue: number): number; +/** Slider Bar control, returns selected value */ +declare function guiSliderBar(bounds: Rectangle, textLeft: string, textRight: string, value: number, minValue: number, maxValue: number): number; +/** Progress Bar control, shows current progress value */ +declare function guiProgressBar(bounds: Rectangle, textLeft: string, textRight: string, value: number, minValue: number, maxValue: number): number; +/** Status Bar control, shows info text */ +declare function guiStatusBar(bounds: Rectangle, text: string): void; +/** Dummy control for placeholders */ +declare function guiDummyRec(bounds: Rectangle, text: string): void; +/** Grid control, returns mouse cell position */ +declare function guiGrid(bounds: Rectangle, text: string, spacing: number, subdivs: number): Vector2; +/** Message Box control, displays a message */ +declare function guiMessageBox(bounds: Rectangle, title: string, message: string, buttons: string): number; +/** Color Picker control (multiple color controls) */ +declare function guiColorPicker(bounds: Rectangle, text: string, color: Color): Color; +/** Color Panel control */ +declare function guiColorPanel(bounds: Rectangle, text: string, color: Color): Color; +/** Color Bar Alpha control */ +declare function guiColorBarAlpha(bounds: Rectangle, text: string, alpha: number): number; +/** Color Bar Hue control */ +declare function guiColorBarHue(bounds: Rectangle, text: string, value: number): number; +/** Load style file over global style variable (.rgs) */ +declare function guiLoadStyle(fileName: string): void; +/** Load style default over global style */ +declare function guiLoadStyleDefault(): void; +/** Get text with icon id prepended (if supported) */ +declare function guiIconText(iconId: number, text: string): string; +/** */ +declare function guiDrawIcon(iconId: number, posX: number, posY: number, pixelSize: number, color: Color): void; +/** Set icon scale (1 by default) */ +declare function guiSetIconScale(scale: number): void; +/** Set icon pixel value */ +declare function guiSetIconPixel(iconId: number, x: number, y: number): void; +/** Clear icon pixel value */ +declare function guiClearIconPixel(iconId: number, x: number, y: number): void; +/** Check icon pixel value */ +declare function guiCheckIconPixel(iconId: number, x: number, y: number): boolean; +/** Linear Easing functions */ +declare function easeLinearNone(t: number, b: number, c: number, d: number): number; +/** Ease: Linear */ +declare function easeLinearIn(t: number, b: number, c: number, d: number): number; +/** Ease: Linear In */ +declare function easeLinearOut(t: number, b: number, c: number, d: number): number; +/** Ease: Linear Out */ +declare function easeLinearInOut(t: number, b: number, c: number, d: number): number; +/** Sine Easing functions */ +declare function easeSineIn(t: number, b: number, c: number, d: number): number; +/** Ease: Sine In */ +declare function easeSineOut(t: number, b: number, c: number, d: number): number; +/** Ease: Sine Out */ +declare function easeSineInOut(t: number, b: number, c: number, d: number): number; +/** Circular Easing functions */ +declare function easeCircIn(t: number, b: number, c: number, d: number): number; +/** Ease: Circular In */ +declare function easeCircOut(t: number, b: number, c: number, d: number): number; +/** Ease: Circular Out */ +declare function easeCircInOut(t: number, b: number, c: number, d: number): number; +/** Cubic Easing functions */ +declare function easeCubicIn(t: number, b: number, c: number, d: number): number; +/** Ease: Cubic In */ +declare function easeCubicOut(t: number, b: number, c: number, d: number): number; +/** Ease: Cubic Out */ +declare function easeCubicInOut(t: number, b: number, c: number, d: number): number; +/** Quadratic Easing functions */ +declare function easeQuadIn(t: number, b: number, c: number, d: number): number; +/** Ease: Quadratic In */ +declare function easeQuadOut(t: number, b: number, c: number, d: number): number; +/** Ease: Quadratic Out */ +declare function easeQuadInOut(t: number, b: number, c: number, d: number): number; +/** Exponential Easing functions */ +declare function easeExpoIn(t: number, b: number, c: number, d: number): number; +/** Ease: Exponential In */ +declare function easeExpoOut(t: number, b: number, c: number, d: number): number; +/** Ease: Exponential Out */ +declare function easeExpoInOut(t: number, b: number, c: number, d: number): number; +/** Back Easing functions */ +declare function easeBackIn(t: number, b: number, c: number, d: number): number; +/** Bounce Easing functions */ +declare function easeBounceOut(t: number, b: number, c: number, d: number): number; +/** Ease: Bounce In */ +declare function easeBounceInOut(t: number, b: number, c: number, d: number): number; +/** Elastic Easing functions */ +declare function easeElasticIn(t: number, b: number, c: number, d: number): number; /** (PI/180.0) */ declare var DEG2RAD: number; /** (180.0/PI) */ diff --git a/examples/shapes/shapes_draw_circle_sector.c b/examples/shapes/shapes_draw_circle_sector.c deleted file mode 100644 index c95f436..0000000 --- a/examples/shapes/shapes_draw_circle_sector.c +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - draw circle sector (with gui options) -* -* Example originally created with raylib 2.5, last time updated with raylib 2.5 -* -* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, -* BSD-like license that allows static linking with closed source software -* -* Copyright (c) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include - -#define RAYGUI_IMPLEMENTATION -#include "raygui.h" // Required for GUI controls - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector"); - - Vector2 center = {(GetScreenWidth() - 300)/2.0f, GetScreenHeight()/2.0f }; - - float outerRadius = 180.0f; - float startAngle = 0.0f; - float endAngle = 180.0f; - int segments = 0; - int minSegments = 4; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // NOTE: All variables update happens inside GUI control functions - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f)); - DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f)); - - DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3f)); - DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6f)); - - // Draw GUI controls - //------------------------------------------------------------------------------ - startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", NULL, startAngle, 0, 720); - endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, endAngle, 0, 720); - - outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, outerRadius, 0, 200); - segments = (int)GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, (float)segments, 0, 100); - //------------------------------------------------------------------------------ - - minSegments = (int)ceilf((endAngle - startAngle) / 90); - DrawText(TextFormat("MODE: %s", (segments >= minSegments)? "MANUAL" : "AUTO"), 600, 200, 10, (segments >= minSegments)? MAROON : DARKGRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/examples/shapes/shapes_draw_circle_sector.js b/examples/shapes/shapes_draw_circle_sector.js new file mode 100644 index 0000000..df981ca --- /dev/null +++ b/examples/shapes/shapes_draw_circle_sector.js @@ -0,0 +1,74 @@ +/******************************************************************************************* +* +* raylib [shapes] example - draw circle sector (with gui options) +* +* Example originally created with raylib 2.5, last time updated with raylib 2.5 +* +* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) +* +* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software +* +* Copyright (c) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) +* +********************************************************************************************/ +// Initialization +//-------------------------------------------------------------------------------------- +const screenWidth = 800; +const screenHeight = 450; + +initWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector"); + +const center = new Vector2((getScreenWidth() - 300)/2.0, getScreenHeight()/2.0); + +let outerRadius = 180.0; +let startAngle = 0.0; +let endAngle = 180.0; +let segments = 0; +let minSegments = 4; + +setTargetFPS(60); // Set our game to run at 60 frames-per-second +//-------------------------------------------------------------------------------------- + +// Main game loop +while (!windowShouldClose()) // Detect window close button or ESC key +{ + // Update + //---------------------------------------------------------------------------------- + // NOTE: All variables update happens inside GUI control functions + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + beginDrawing(); + + clearBackground(RAYWHITE); + + drawLine(500, 0, 500, getScreenHeight(), fade(LIGHTGRAY, 0.6)); + drawRectangle(500, 0, getScreenWidth() - 500, getScreenHeight(), fade(LIGHTGRAY, 0.3)); + + drawCircleSector(center, outerRadius, startAngle, endAngle, segments, fade(MAROON, 0.3)); + drawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, fade(MAROON, 0.6)); + + // Draw GUI controls + //------------------------------------------------------------------------------ + startAngle = guiSliderBar(new Rectangle(600, 40, 120, 20), "StartAngle", startAngle, startAngle, 0, 720); + endAngle = guiSliderBar(new Rectangle(600, 70, 120, 20), "EndAngle", endAngle, endAngle, 0, 720); + + outerRadius = guiSliderBar(new Rectangle(600, 140, 120, 20), "Radius", Math.round(outerRadius), outerRadius, 0, 200); + segments = guiSliderBar(new Rectangle(600, 170, 120, 20), "Segments", Math.floor(segments), segments, 0, 100); + //------------------------------------------------------------------------------ + + minSegments = Math.ceil((endAngle - startAngle) / 90); + drawText("MODE: " + (segments >= minSegments) ? "MANUAL" : "AUTO", 600, 200, 10, (segments >= minSegments)? MAROON : DARKGRAY); + + drawFPS(10, 10); + + endDrawing(); + //---------------------------------------------------------------------------------- +} + +// De-Initialization +//-------------------------------------------------------------------------------------- +closeWindow(); // Close window and OpenGL context +//-------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/generate-bindings.js b/generate-bindings.js index 5da683e..548989e 100644 --- a/generate-bindings.js +++ b/generate-bindings.js @@ -350,7 +350,7 @@ class HeaderParser { return input.split('\n').map(x => x.replace("// ", "")).join('\n').trim(); } parseFunctionDefinitions(input) { - const matches = [...input.matchAll(/^[A-Z]+API (.+?)(\w+)\(([^\)]+)\);(?:[^\/]+\/\/ (.+))?/gm)]; + const matches = [...input.matchAll(/^[A-Z]+ (.+?)(\w+)\(([^\)]+)\);(?: +\/\/ (.+))?$/gm)]; return matches.map(groups => ({ returnType: groups[1].trim(), name: groups[2], @@ -358,14 +358,15 @@ class HeaderParser { description: groups[4] || "" })); } - parseFunctions(input) { - const matches = [...input.matchAll(/((?:\/\/ .+\n)*)[A-Z]+API\s+([\w<>]+)\s+([\w<>]+)\((.*)\)/gm)]; - console.log(matches[0]); + parseFunctions(input, noPrefix = false) { + const matches = noPrefix + ? [...input.matchAll(/((?:\/\/.+\n)+)^(.+?)(\w+)\(([^\)]+)\)/gm)] + : [...input.matchAll(/((?:\/\/.+\n)+)^[A-Z]+ (.+?)(\w+)\(([^\)]+)\)/gm)]; return matches.map(groups => ({ - returnType: groups[1].trim(), - name: groups[2], - params: this.parseFunctionArgs(groups[3]), - description: groups[4] || "" + returnType: groups[2].trim(), + name: groups[3], + params: this.parseFunctionArgs(groups[4]), + description: groups[1] ? this.parseComments(groups[1]) : "" })); } parseFunctionArgs(input) { @@ -968,28 +969,6 @@ const fs_1 = __webpack_require__(/*! fs */ "fs"); const api_1 = __webpack_require__(/*! ./api */ "./src/api.ts"); const raylib_header_1 = __webpack_require__(/*! ./raylib-header */ "./src/raylib-header.ts"); const header_parser_1 = __webpack_require__(/*! ./header-parser */ "./src/header-parser.ts"); -function parseHeader(path, prefix) { - const i = (0, fs_1.readFileSync)(path, 'utf8'); - const regex = new RegExp(`((?:\\/\\/ .+\\n)*)${prefix}\\s+([\\w<>]+)\\s+([\\w<>]+)\\((.*)\\)`, 'gm'); - const m = [...i.matchAll(regex)]; - const res = m.map(groups => { - const args = groups[4].split(',').filter(x => x !== 'void').map(arg => { - arg = arg.trim().replace(" *", "* "); - const frags = arg.split(' '); - const name = frags.pop(); - const type = frags.join(' ').replace("*", " *"); - return { name: name || "", type: type }; - }); - const comments = groups[1].split('\n').map(x => x.replace("// ", "")).join('\n').trim(); - return { - name: groups[3], - returnType: groups[2], - params: args, - description: comments - }; - }); - return res; -} function main() { // Load the pre-generated raylib api const api = JSON.parse((0, fs_1.readFileSync)("thirdparty/raylib/parser/output/raylib_api.json", 'utf8')); @@ -999,21 +978,35 @@ function main() { returnType: "void", params: [{ type: "Model *", name: "model" }, { type: "int", name: "materialIndex" }, { type: "Material", name: "material" }] }); - const rguiHeader = (0, fs_1.readFileSync)("thirdparty/raylib/examples/shapes/raygui.h", "utf8"); const parser = new header_parser_1.HeaderParser(); - //writeFileSync("enums.json",JSON.stringify(parser.parseEnums(rayguiHeader))) - //writeFileSync("functions.json",JSON.stringify(parser.parseFunctions(rayguiHeader))) const rmathHeader = (0, fs_1.readFileSync)("thirdparty/raylib/src/raymath.h", "utf8"); - const mathApi = parseHeader("thirdparty/raylib/src/raymath.h", "RMAPI"); + const mathApi = parser.parseFunctions(rmathHeader); mathApi.forEach(x => api.functions.push(x)); const rcameraHeader = (0, fs_1.readFileSync)("thirdparty/raylib/src/rcamera.h", "utf8"); - const cameraApi = parseHeader("thirdparty/raylib/src/rcamera.h", "RLAPI"); - //cameraApi.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) + const cameraApi = parser.parseFunctionDefinitions(rcameraHeader); cameraApi.forEach(x => api.functions.push(x)); + const rguiHeader = (0, fs_1.readFileSync)("thirdparty/raylib/examples/shapes/raygui.h", "utf8"); + const rguiFunctions = parser.parseFunctionDefinitions(rguiHeader); + const rguiEnums = parser.parseFunctionDefinitions(rguiHeader); + //rguiApi.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) + rguiFunctions.forEach(x => api.functions.push(x)); + const rlightsHeader = (0, fs_1.readFileSync)("thirdparty/raylib/examples/shaders/rlights.h", "utf8"); + const rlightsFunctions = parser.parseFunctions(rlightsHeader, true); + api.functions.push(rlightsFunctions[0]); + api.functions.push(rlightsFunctions[1]); + const reasingsHeader = (0, fs_1.readFileSync)("thirdparty/raylib/examples/shapes/reasings.h", "utf8"); + const reasingsFunctions = parser.parseFunctions(reasingsHeader); + //reasingsFunctions.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) + reasingsFunctions.forEach(x => api.functions.push(x)); const apiDesc = new api_1.ApiDescription(api); const core = new raylib_header_1.RayLibHeader("raylib_core", apiDesc); core.includes.include("raymath.h"); core.includes.include("rcamera.h"); + core.includes.line("#define RAYGUI_IMPLEMENTATION"); + core.includes.include("raygui.h"); + core.includes.line("#define RLIGHTS_IMPLEMENTATION"); + core.includes.include("rlights.h"); + core.includes.include("reasings.h"); core.addApiStructByName("Color", { properties: { r: { get: true, set: true }, @@ -1944,6 +1937,89 @@ function main() { core.addApiFunctionByName("CameraRoll"); core.addApiFunctionByName("GetCameraViewMatrix"); core.addApiFunctionByName("GetCameraProjectionMatrix"); + // module: rgui + core.addApiFunctionByName("GuiEnable"); + core.addApiFunctionByName("GuiDisable"); + core.addApiFunctionByName("GuiLock"); + core.addApiFunctionByName("GuiUnlock"); + core.addApiFunctionByName("GuiIsLocked"); + core.addApiFunctionByName("GuiFade"); + core.addApiFunctionByName("GuiSetState"); + core.addApiFunctionByName("GuiGetState"); + core.addApiFunctionByName("GuiSetFont"); + core.addApiFunctionByName("GuiGetFont"); + core.addApiFunctionByName("GuiSetStyle"); + core.addApiFunctionByName("GuiGetStyle"); + core.addApiFunctionByName("GuiWindowBox"); + core.addApiFunctionByName("GuiGroupBox"); + core.addApiFunctionByName("GuiLine"); + core.addApiFunctionByName("GuiPanel"); + core.addApiFunctionByName("GuiScrollPanel"); + core.addApiFunctionByName("GuiLabel"); + core.addApiFunctionByName("GuiButton"); + core.addApiFunctionByName("GuiLabelButton"); + core.addApiFunctionByName("GuiToggle"); + core.addApiFunctionByName("GuiToggleGroup"); + core.addApiFunctionByName("GuiCheckBox"); + core.addApiFunctionByName("GuiComboBox"); + //core.addApiFunctionByName("GuiDropdownBox") + //core.addApiFunctionByName("GuiSpinner") + //core.addApiFunctionByName("GuiValueBox") + core.addApiFunctionByName("GuiTextBox"); + core.addApiFunctionByName("GuiTextBoxMulti"); + core.addApiFunctionByName("GuiSlider"); + core.addApiFunctionByName("GuiSliderBar"); + core.addApiFunctionByName("GuiProgressBar"); + core.addApiFunctionByName("GuiStatusBar"); + core.addApiFunctionByName("GuiDummyRec"); + core.addApiFunctionByName("GuiGrid"); + //core.addApiFunctionByName("GuiListView") + //core.addApiFunctionByName("GuiListViewEx") + core.addApiFunctionByName("GuiMessageBox"); + //core.addApiFunctionByName("GuiTextInputBox") + core.addApiFunctionByName("GuiColorPicker"); + core.addApiFunctionByName("GuiColorPanel"); + core.addApiFunctionByName("GuiColorBarAlpha"); + core.addApiFunctionByName("GuiColorBarHue"); + core.addApiFunctionByName("GuiLoadStyle"); + core.addApiFunctionByName("GuiLoadStyleDefault"); + core.addApiFunctionByName("GuiIconText"); + core.addApiFunctionByName("GuiDrawIcon"); + //core.addApiFunctionByName("GuiGetIcons") + //core.addApiFunctionByName("GuiGetIconData") + //core.addApiFunctionByName("GuiSetIconData") + core.addApiFunctionByName("GuiSetIconScale"); + core.addApiFunctionByName("GuiSetIconPixel"); + core.addApiFunctionByName("GuiClearIconPixel"); + core.addApiFunctionByName("GuiCheckIconPixel"); + // module: rlights + // TODO: Parse and support light struct + // core.addApiFunctionByName("CreateLight") + // core.addApiFunctionByName("UpdateLightValues") + // module: reasings + core.addApiFunctionByName("EaseLinearNone"); + core.addApiFunctionByName("EaseLinearIn"); + core.addApiFunctionByName("EaseLinearOut"); + core.addApiFunctionByName("EaseLinearInOut"); + core.addApiFunctionByName("EaseSineIn"); + core.addApiFunctionByName("EaseSineOut"); + core.addApiFunctionByName("EaseSineInOut"); + core.addApiFunctionByName("EaseCircIn"); + core.addApiFunctionByName("EaseCircOut"); + core.addApiFunctionByName("EaseCircInOut"); + core.addApiFunctionByName("EaseCubicIn"); + core.addApiFunctionByName("EaseCubicOut"); + core.addApiFunctionByName("EaseCubicInOut"); + core.addApiFunctionByName("EaseQuadIn"); + core.addApiFunctionByName("EaseQuadOut"); + core.addApiFunctionByName("EaseQuadInOut"); + core.addApiFunctionByName("EaseExpoIn"); + core.addApiFunctionByName("EaseExpoOut"); + core.addApiFunctionByName("EaseExpoInOut"); + core.addApiFunctionByName("EaseBackIn"); + core.addApiFunctionByName("EaseBounceOut"); + core.addApiFunctionByName("EaseBounceInOut"); + core.addApiFunctionByName("EaseElasticIn"); api.defines.filter(x => x.type === "COLOR").map(x => ({ name: x.name, description: x.description, values: (x.value.match(/\{([^}]+)\}/) || "")[1].split(',').map(x => x.trim()) })).forEach(x => { core.exportGlobalStruct("Color", x.name, x.values, x.description); }); diff --git a/src/bindings/js_raylib_core.h b/src/bindings/js_raylib_core.h index faa796d..b22971b 100644 --- a/src/bindings/js_raylib_core.h +++ b/src/bindings/js_raylib_core.h @@ -9,6 +9,11 @@ #include #include #include +#define RAYGUI_IMPLEMENTATION +#include +#define RLIGHTS_IMPLEMENTATION +#include +#include #ifndef countof #define countof(x) (sizeof(x) / sizeof((x)[0])) @@ -8462,6 +8467,936 @@ static JSValue js_getCameraProjectionMatrix(JSContext * ctx, JSValueConst this_v return ret; } +static JSValue js_guiEnable(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + GuiEnable(); + return JS_UNDEFINED; +} + +static JSValue js_guiDisable(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + GuiDisable(); + return JS_UNDEFINED; +} + +static JSValue js_guiLock(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + GuiLock(); + return JS_UNDEFINED; +} + +static JSValue js_guiUnlock(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + GuiUnlock(); + return JS_UNDEFINED; +} + +static JSValue js_guiIsLocked(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + bool returnVal = GuiIsLocked(); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_guiFade(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_alpha; + JS_ToFloat64(ctx, &_double_alpha, argv[0]); + float alpha = (float)_double_alpha; + GuiFade(alpha); + return JS_UNDEFINED; +} + +static JSValue js_guiSetState(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int state; + JS_ToInt32(ctx, &state, argv[0]); + GuiSetState(state); + return JS_UNDEFINED; +} + +static JSValue js_guiGetState(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int returnVal = GuiGetState(); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiSetFont(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id); + if(font_ptr == NULL) return JS_EXCEPTION; + Font font = *font_ptr; + GuiSetFont(font); + return JS_UNDEFINED; +} + +static JSValue js_guiGetFont(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Font returnVal = GuiGetFont(); + Font* ret_ptr = (Font*)js_malloc(ctx, sizeof(Font)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Font_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_guiSetStyle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int control; + JS_ToInt32(ctx, &control, argv[0]); + int property; + JS_ToInt32(ctx, &property, argv[1]); + int value; + JS_ToInt32(ctx, &value, argv[2]); + GuiSetStyle(control, property, value); + return JS_UNDEFINED; +} + +static JSValue js_guiGetStyle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int control; + JS_ToInt32(ctx, &control, argv[0]); + int property; + JS_ToInt32(ctx, &property, argv[1]); + int returnVal = GuiGetStyle(control, property); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiWindowBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * title = (const char *)JS_ToCString(ctx, argv[1]); + bool returnVal = GuiWindowBox(bounds, title); + JS_FreeCString(ctx, title); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_guiGroupBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + GuiGroupBox(bounds, text); + JS_FreeCString(ctx, text); + return JS_UNDEFINED; +} + +static JSValue js_guiLine(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + GuiLine(bounds, text); + JS_FreeCString(ctx, text); + return JS_UNDEFINED; +} + +static JSValue js_guiPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + GuiPanel(bounds, text); + JS_FreeCString(ctx, text); + return JS_UNDEFINED; +} + +static JSValue js_guiScrollPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + Rectangle* content_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[2], js_Rectangle_class_id); + if(content_ptr == NULL) return JS_EXCEPTION; + Rectangle content = *content_ptr; + Vector2* scroll = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(scroll == NULL) return JS_EXCEPTION; + Rectangle returnVal = GuiScrollPanel(bounds, text, content, scroll); + JS_FreeCString(ctx, text); + Rectangle* ret_ptr = (Rectangle*)js_malloc(ctx, sizeof(Rectangle)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Rectangle_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_guiLabel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + GuiLabel(bounds, text); + JS_FreeCString(ctx, text); + return JS_UNDEFINED; +} + +static JSValue js_guiButton(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + bool returnVal = GuiButton(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_guiLabelButton(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + bool returnVal = GuiLabelButton(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_guiToggle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + bool active = JS_ToBool(ctx, argv[2]); + bool returnVal = GuiToggle(bounds, text, active); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_guiToggleGroup(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + int active; + JS_ToInt32(ctx, &active, argv[2]); + int returnVal = GuiToggleGroup(bounds, text, active); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiCheckBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + bool checked = JS_ToBool(ctx, argv[2]); + bool returnVal = GuiCheckBox(bounds, text, checked); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_guiComboBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + int active; + JS_ToInt32(ctx, &active, argv[2]); + int returnVal = GuiComboBox(bounds, text, active); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiTextBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + char * text = (char *)JS_ToCString(ctx, argv[1]); + int textSize; + JS_ToInt32(ctx, &textSize, argv[2]); + bool editMode = JS_ToBool(ctx, argv[3]); + bool returnVal = GuiTextBox(bounds, text, textSize, editMode); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_guiTextBoxMulti(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + char * text = (char *)JS_ToCString(ctx, argv[1]); + int textSize; + JS_ToInt32(ctx, &textSize, argv[2]); + bool editMode = JS_ToBool(ctx, argv[3]); + bool returnVal = GuiTextBoxMulti(bounds, text, textSize, editMode); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_guiSlider(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * textLeft = (const char *)JS_ToCString(ctx, argv[1]); + const char * textRight = (const char *)JS_ToCString(ctx, argv[2]); + double _double_value; + JS_ToFloat64(ctx, &_double_value, argv[3]); + float value = (float)_double_value; + double _double_minValue; + JS_ToFloat64(ctx, &_double_minValue, argv[4]); + float minValue = (float)_double_minValue; + double _double_maxValue; + JS_ToFloat64(ctx, &_double_maxValue, argv[5]); + float maxValue = (float)_double_maxValue; + float returnVal = GuiSlider(bounds, textLeft, textRight, value, minValue, maxValue); + JS_FreeCString(ctx, textLeft); + JS_FreeCString(ctx, textRight); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_guiSliderBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * textLeft = (const char *)JS_ToCString(ctx, argv[1]); + const char * textRight = (const char *)JS_ToCString(ctx, argv[2]); + double _double_value; + JS_ToFloat64(ctx, &_double_value, argv[3]); + float value = (float)_double_value; + double _double_minValue; + JS_ToFloat64(ctx, &_double_minValue, argv[4]); + float minValue = (float)_double_minValue; + double _double_maxValue; + JS_ToFloat64(ctx, &_double_maxValue, argv[5]); + float maxValue = (float)_double_maxValue; + float returnVal = GuiSliderBar(bounds, textLeft, textRight, value, minValue, maxValue); + JS_FreeCString(ctx, textLeft); + JS_FreeCString(ctx, textRight); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_guiProgressBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * textLeft = (const char *)JS_ToCString(ctx, argv[1]); + const char * textRight = (const char *)JS_ToCString(ctx, argv[2]); + double _double_value; + JS_ToFloat64(ctx, &_double_value, argv[3]); + float value = (float)_double_value; + double _double_minValue; + JS_ToFloat64(ctx, &_double_minValue, argv[4]); + float minValue = (float)_double_minValue; + double _double_maxValue; + JS_ToFloat64(ctx, &_double_maxValue, argv[5]); + float maxValue = (float)_double_maxValue; + float returnVal = GuiProgressBar(bounds, textLeft, textRight, value, minValue, maxValue); + JS_FreeCString(ctx, textLeft); + JS_FreeCString(ctx, textRight); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_guiStatusBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + GuiStatusBar(bounds, text); + JS_FreeCString(ctx, text); + return JS_UNDEFINED; +} + +static JSValue js_guiDummyRec(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + GuiDummyRec(bounds, text); + JS_FreeCString(ctx, text); + return JS_UNDEFINED; +} + +static JSValue js_guiGrid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + double _double_spacing; + JS_ToFloat64(ctx, &_double_spacing, argv[2]); + float spacing = (float)_double_spacing; + int subdivs; + JS_ToInt32(ctx, &subdivs, argv[3]); + Vector2 returnVal = GuiGrid(bounds, text, spacing, subdivs); + JS_FreeCString(ctx, text); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_guiMessageBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * title = (const char *)JS_ToCString(ctx, argv[1]); + const char * message = (const char *)JS_ToCString(ctx, argv[2]); + const char * buttons = (const char *)JS_ToCString(ctx, argv[3]); + int returnVal = GuiMessageBox(bounds, title, message, buttons); + JS_FreeCString(ctx, title); + JS_FreeCString(ctx, message); + JS_FreeCString(ctx, buttons); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiColorPicker(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + Color returnVal = GuiColorPicker(bounds, text, color); + JS_FreeCString(ctx, text); + Color* ret_ptr = (Color*)js_malloc(ctx, sizeof(Color)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Color_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_guiColorPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + Color returnVal = GuiColorPanel(bounds, text, color); + JS_FreeCString(ctx, text); + Color* ret_ptr = (Color*)js_malloc(ctx, sizeof(Color)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Color_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_guiColorBarAlpha(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + double _double_alpha; + JS_ToFloat64(ctx, &_double_alpha, argv[2]); + float alpha = (float)_double_alpha; + float returnVal = GuiColorBarAlpha(bounds, text, alpha); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_guiColorBarHue(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + double _double_value; + JS_ToFloat64(ctx, &_double_value, argv[2]); + float value = (float)_double_value; + float returnVal = GuiColorBarHue(bounds, text, value); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_guiLoadStyle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * fileName = (const char *)JS_ToCString(ctx, argv[0]); + GuiLoadStyle(fileName); + JS_FreeCString(ctx, fileName); + return JS_UNDEFINED; +} + +static JSValue js_guiLoadStyleDefault(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + GuiLoadStyleDefault(); + return JS_UNDEFINED; +} + +static JSValue js_guiIconText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int iconId; + JS_ToInt32(ctx, &iconId, argv[0]); + const char * text = (const char *)JS_ToCString(ctx, argv[1]); + const char * returnVal = GuiIconText(iconId, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewString(ctx, returnVal); + return ret; +} + +static JSValue js_guiDrawIcon(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int iconId; + JS_ToInt32(ctx, &iconId, argv[0]); + int posX; + JS_ToInt32(ctx, &posX, argv[1]); + int posY; + JS_ToInt32(ctx, &posY, argv[2]); + int pixelSize; + JS_ToInt32(ctx, &pixelSize, argv[3]); + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + GuiDrawIcon(iconId, posX, posY, pixelSize, color); + return JS_UNDEFINED; +} + +static JSValue js_guiSetIconScale(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + unsigned int scale; + JS_ToUint32(ctx, &scale, argv[0]); + GuiSetIconScale(scale); + return JS_UNDEFINED; +} + +static JSValue js_guiSetIconPixel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int iconId; + JS_ToInt32(ctx, &iconId, argv[0]); + int x; + JS_ToInt32(ctx, &x, argv[1]); + int y; + JS_ToInt32(ctx, &y, argv[2]); + GuiSetIconPixel(iconId, x, y); + return JS_UNDEFINED; +} + +static JSValue js_guiClearIconPixel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int iconId; + JS_ToInt32(ctx, &iconId, argv[0]); + int x; + JS_ToInt32(ctx, &x, argv[1]); + int y; + JS_ToInt32(ctx, &y, argv[2]); + GuiClearIconPixel(iconId, x, y); + return JS_UNDEFINED; +} + +static JSValue js_guiCheckIconPixel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int iconId; + JS_ToInt32(ctx, &iconId, argv[0]); + int x; + JS_ToInt32(ctx, &x, argv[1]); + int y; + JS_ToInt32(ctx, &y, argv[2]); + bool returnVal = GuiCheckIconPixel(iconId, x, y); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_easeLinearNone(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseLinearNone(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeLinearIn(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseLinearIn(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeLinearOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseLinearOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeLinearInOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseLinearInOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeSineIn(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseSineIn(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeSineOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseSineOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeSineInOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseSineInOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeCircIn(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseCircIn(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeCircOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseCircOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeCircInOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseCircInOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeCubicIn(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseCubicIn(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeCubicOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseCubicOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeCubicInOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseCubicInOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeQuadIn(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseQuadIn(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeQuadOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseQuadOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeQuadInOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseQuadInOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeExpoIn(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseExpoIn(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeExpoOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseExpoOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeExpoInOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseExpoInOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeBackIn(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseBackIn(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeBounceOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseBounceOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeBounceInOut(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseBounceInOut(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_easeElasticIn(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[0]); + float t = (float)_double_t; + double _double_b; + JS_ToFloat64(ctx, &_double_b, argv[1]); + float b = (float)_double_b; + double _double_c; + JS_ToFloat64(ctx, &_double_c, argv[2]); + float c = (float)_double_c; + double _double_d; + JS_ToFloat64(ctx, &_double_d, argv[3]); + float d = (float)_double_d; + float returnVal = EaseElasticIn(t, b, c, d); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("initWindow",3,js_initWindow), JS_CFUNC_DEF("windowShouldClose",0,js_windowShouldClose), @@ -8997,6 +9932,74 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("cameraRoll",2,js_cameraRoll), JS_CFUNC_DEF("getCameraViewMatrix",1,js_getCameraViewMatrix), JS_CFUNC_DEF("getCameraProjectionMatrix",2,js_getCameraProjectionMatrix), + JS_CFUNC_DEF("guiEnable",0,js_guiEnable), + JS_CFUNC_DEF("guiDisable",0,js_guiDisable), + JS_CFUNC_DEF("guiLock",0,js_guiLock), + JS_CFUNC_DEF("guiUnlock",0,js_guiUnlock), + JS_CFUNC_DEF("guiIsLocked",0,js_guiIsLocked), + JS_CFUNC_DEF("guiFade",1,js_guiFade), + JS_CFUNC_DEF("guiSetState",1,js_guiSetState), + JS_CFUNC_DEF("guiGetState",0,js_guiGetState), + JS_CFUNC_DEF("guiSetFont",1,js_guiSetFont), + JS_CFUNC_DEF("guiGetFont",0,js_guiGetFont), + JS_CFUNC_DEF("guiSetStyle",3,js_guiSetStyle), + JS_CFUNC_DEF("guiGetStyle",2,js_guiGetStyle), + JS_CFUNC_DEF("guiWindowBox",2,js_guiWindowBox), + JS_CFUNC_DEF("guiGroupBox",2,js_guiGroupBox), + JS_CFUNC_DEF("guiLine",2,js_guiLine), + JS_CFUNC_DEF("guiPanel",2,js_guiPanel), + JS_CFUNC_DEF("guiScrollPanel",4,js_guiScrollPanel), + JS_CFUNC_DEF("guiLabel",2,js_guiLabel), + JS_CFUNC_DEF("guiButton",2,js_guiButton), + JS_CFUNC_DEF("guiLabelButton",2,js_guiLabelButton), + JS_CFUNC_DEF("guiToggle",3,js_guiToggle), + JS_CFUNC_DEF("guiToggleGroup",3,js_guiToggleGroup), + JS_CFUNC_DEF("guiCheckBox",3,js_guiCheckBox), + JS_CFUNC_DEF("guiComboBox",3,js_guiComboBox), + JS_CFUNC_DEF("guiTextBox",4,js_guiTextBox), + JS_CFUNC_DEF("guiTextBoxMulti",4,js_guiTextBoxMulti), + JS_CFUNC_DEF("guiSlider",6,js_guiSlider), + JS_CFUNC_DEF("guiSliderBar",6,js_guiSliderBar), + JS_CFUNC_DEF("guiProgressBar",6,js_guiProgressBar), + JS_CFUNC_DEF("guiStatusBar",2,js_guiStatusBar), + JS_CFUNC_DEF("guiDummyRec",2,js_guiDummyRec), + JS_CFUNC_DEF("guiGrid",4,js_guiGrid), + JS_CFUNC_DEF("guiMessageBox",4,js_guiMessageBox), + JS_CFUNC_DEF("guiColorPicker",3,js_guiColorPicker), + JS_CFUNC_DEF("guiColorPanel",3,js_guiColorPanel), + JS_CFUNC_DEF("guiColorBarAlpha",3,js_guiColorBarAlpha), + JS_CFUNC_DEF("guiColorBarHue",3,js_guiColorBarHue), + JS_CFUNC_DEF("guiLoadStyle",1,js_guiLoadStyle), + JS_CFUNC_DEF("guiLoadStyleDefault",0,js_guiLoadStyleDefault), + JS_CFUNC_DEF("guiIconText",2,js_guiIconText), + JS_CFUNC_DEF("guiDrawIcon",5,js_guiDrawIcon), + JS_CFUNC_DEF("guiSetIconScale",1,js_guiSetIconScale), + JS_CFUNC_DEF("guiSetIconPixel",3,js_guiSetIconPixel), + JS_CFUNC_DEF("guiClearIconPixel",3,js_guiClearIconPixel), + JS_CFUNC_DEF("guiCheckIconPixel",3,js_guiCheckIconPixel), + JS_CFUNC_DEF("easeLinearNone",4,js_easeLinearNone), + JS_CFUNC_DEF("easeLinearIn",4,js_easeLinearIn), + JS_CFUNC_DEF("easeLinearOut",4,js_easeLinearOut), + JS_CFUNC_DEF("easeLinearInOut",4,js_easeLinearInOut), + JS_CFUNC_DEF("easeSineIn",4,js_easeSineIn), + JS_CFUNC_DEF("easeSineOut",4,js_easeSineOut), + JS_CFUNC_DEF("easeSineInOut",4,js_easeSineInOut), + JS_CFUNC_DEF("easeCircIn",4,js_easeCircIn), + JS_CFUNC_DEF("easeCircOut",4,js_easeCircOut), + JS_CFUNC_DEF("easeCircInOut",4,js_easeCircInOut), + JS_CFUNC_DEF("easeCubicIn",4,js_easeCubicIn), + JS_CFUNC_DEF("easeCubicOut",4,js_easeCubicOut), + JS_CFUNC_DEF("easeCubicInOut",4,js_easeCubicInOut), + JS_CFUNC_DEF("easeQuadIn",4,js_easeQuadIn), + JS_CFUNC_DEF("easeQuadOut",4,js_easeQuadOut), + JS_CFUNC_DEF("easeQuadInOut",4,js_easeQuadInOut), + JS_CFUNC_DEF("easeExpoIn",4,js_easeExpoIn), + JS_CFUNC_DEF("easeExpoOut",4,js_easeExpoOut), + JS_CFUNC_DEF("easeExpoInOut",4,js_easeExpoInOut), + JS_CFUNC_DEF("easeBackIn",4,js_easeBackIn), + JS_CFUNC_DEF("easeBounceOut",4,js_easeBounceOut), + JS_CFUNC_DEF("easeBounceInOut",4,js_easeBounceInOut), + JS_CFUNC_DEF("easeElasticIn",4,js_easeElasticIn), }; static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { diff --git a/src/quickjs.c b/src/quickjs.c index 52d12c3..5b83090 100644 --- a/src/quickjs.c +++ b/src/quickjs.c @@ -317,6 +317,7 @@ int app_run_quickjs(int argc, char** argv){ ChangeDirectory(originalCwd); js_run(argc, argv); } + return 0; } /* also used to initialize the worker context */