{"id":26225579,"url":"https://github.com/mikedx/flua-web","last_synced_at":"2025-03-12T19:17:17.760Z","repository":{"id":280693254,"uuid":"942850721","full_name":"MikeDX/flua-web","owner":"MikeDX","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-04T19:48:08.000Z","size":119,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T21:49:04.335Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikeDX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-04T19:23:26.000Z","updated_at":"2025-03-04T19:48:11.000Z","dependencies_parsed_at":"2025-03-04T20:39:43.705Z","dependency_job_id":null,"html_url":"https://github.com/MikeDX/flua-web","commit_stats":null,"previous_names":["mikedx/flua-web"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeDX%2Fflua-web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeDX%2Fflua-web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeDX%2Fflua-web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeDX%2Fflua-web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikeDX","download_url":"https://codeload.github.com/MikeDX/flua-web/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243277472,"owners_count":20265352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-12T19:17:17.192Z","updated_at":"2025-03-12T19:17:17.740Z","avatar_url":"https://github.com/MikeDX.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pixi.js with Lua Scripting\n\nThis project integrates Pixi.js v8 as a rendering backend with Lua as a scripting language. It allows you to write Lua code that controls graphics rendered by Pixi.js.\n\n## Live Demo\n\nTry out the live demo at [https://mikedx.github.io/flua-web](https://mikedx.github.io/flua-web)\n\n## Features\n\n- Real-time Lua script editing and execution\n- Pixi.js v8 rendering engine\n- Built-in functions for drawing shapes and manipulating sprites\n- Frame-based animation system\n- Example scripts demonstrating various features\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js (v14 or later recommended)\n- npm (comes with Node.js)\n\n### Installation\n\n1. Clone this repository\n2. Install dependencies:\n\n```bash\nnpm install\n```\n\n3. Start the development server:\n\n```bash\nnpm start\n```\n\n4. Open your browser and navigate to `http://localhost:9000`\n\n### Building for Production\n\nTo build the project for production:\n\n```bash\nnpm run build:prod\n```\n\nThe built files will be in the `dist` directory.\n\n## Usage\n\nThe application is split into two main areas:\n- The left side shows the Pixi.js canvas where your graphics will be rendered\n- The right side contains a Lua code editor where you can write and run scripts\n\n### Lua API\n\nThe following functions are available in the Lua environment:\n\n#### Drawing Functions\n\n- `circle(x, y, radius, vertices, color, outline)`: Draw a circle\n  - `color`: Table with {r, g, b, a} values (0-1) or hex value\n  - `outline`: 0 for filled, 1 for outline\n- `box(x, y, width, height, color, outline)`: Draw a rectangle\n- `drawLine(x1, y1, x2, y2, color, thickness)`: Draw a line\n- `setBackgroundColor(color)`: Set the background color\n- `clear()`: Clear all graphics\n- `update()`: Update the display (yields to next frame)\n\n#### Utility Functions\n\n- `gWidth()`: Get canvas width\n- `gHeight()`: Get canvas height\n- `getFPS()`: Get current FPS\n- `printAt(x, y, text)`: Draw text at position\n- `rnd(max)`: Get random number from 0 to max-1\n\n#### Sprite Functions\n\n- `loadImage(path)`: Load an image texture\n- `createSprite()`: Create a new sprite\n- `setSpriteImage(sprite, texture)`: Set sprite texture\n- `setSpritePosition(sprite, x, y)`: Set sprite position\n- `setSpriteColor(sprite, r, g, b, a)`: Set sprite color/tint\n- `setSpriteSpeed(sprite, {x, y})`: Set sprite movement speed\n- `updateSprites()`: Update all sprites\n- `drawSprites()`: Draw all sprites\n\n### Example Scripts\n\n#### Particles Example\n```lua\n-- Initialize particle system\nlocal particles = {}\nlocal emitterX = gWidth() / 2\nlocal emitterY = gHeight() / 2\nlocal totalTime = 0\nlocal dt = 0.016  -- Fixed time step\n\nwhile true do\n    clear()\n    totalTime = totalTime + dt\n    \n    -- Update and spawn particles\n    -- Move emitter in a circle\n    emitterX = gWidth() / 2 + math.cos(totalTime * 2) * 100\n    emitterY = gHeight() / 2 + math.sin(totalTime * 2) * 100\n    \n    -- Display stats\n    printAt(10, 10, \"FPS: \" .. getFPS())\n    update()\nend\n```\n\n#### Bunny Example\n```lua\nbunny = loadImage(\"assets/wabbit_alpha.png\")\nwhile true do\n    clear()\n    t = touch()\n    if t[0].z then\n        -- Spawn bunnies on click\n        createSprite()\n        setSpriteImage(newbunny, bunny)\n    end\n    updateSprites()\n    drawSprites()\n    update()\nend\n```\n\n## Technical Notes\n\n- Uses frame-based timing for consistent animation\n- Supports both filled and outlined shapes\n- Color values can be specified as RGB tables or hex values\n- Sprites support automatic screen edge collision\n\n## License\n\nThis project is licensed under the ISC License - see the LICENSE file for details.\n\n## Acknowledgments\n\n- [Pixi.js](https://pixijs.com/) - 2D WebGL/WebGPU renderer\n- [Fengari](https://fengari.io/) - Lua VM written in JavaScript ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikedx%2Fflua-web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikedx%2Fflua-web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikedx%2Fflua-web/lists"}