{"id":50823297,"url":"https://github.com/sunsided/bgi","last_synced_at":"2026-06-13T16:11:21.428Z","repository":{"id":360082335,"uuid":"1064358003","full_name":"sunsided/bgi","owner":"sunsided","description":"Borland Graphics Interface ... for Rust","archived":false,"fork":false,"pushed_at":"2026-05-24T22:02:48.000Z","size":437,"stargazers_count":0,"open_issues_count":26,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-25T00:12:29.969Z","etag":null,"topics":["bgi","borland-graphics-interface","graphics","retro","retrocomputing","rust","tui"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/bgi","language":"Rust","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/sunsided.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-25T23:20:55.000Z","updated_at":"2026-05-24T22:25:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sunsided/bgi","commit_stats":null,"previous_names":["sunsided/bgi"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/sunsided/bgi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunsided","download_url":"https://codeload.github.com/sunsided/bgi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fbgi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34290628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bgi","borland-graphics-interface","graphics","retro","retrocomputing","rust","tui"],"created_at":"2026-06-13T16:11:20.795Z","updated_at":"2026-06-13T16:11:21.422Z","avatar_url":"https://github.com/sunsided.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BGI - Borland Graphics Interface for Rust\n\nA modern Rust port of the classic Borland Graphics Interface (BGI) with extensible backends.\n\n## Features\n\n- **Full BGI API compatibility** with modern Rust ergonomics\n- **Multiple graphics backends**: MiniFB (visual), Pixel Buffer (headless/testing), PGM output\n- **Multiple graphics drivers**: CGA, MCGA, EGA, VGA, IBM 8514, Hercules, AT\u0026T 400, PC 3270\n- **Double-buffering support** with active/visual page management\n- **Keyboard and mouse input** handling\n- **16-color EGA/VGA palette** with RGB color support\n- **Line styles and fill patterns** with custom bit patterns\n- **Viewport clipping** and coordinate management\n- **Zero-cost abstractions** with `BatchDrawer` and compile-time optimizations\n- **Modern Rust**: Edition 2024, MSRV 1.90\n\n## Quick Start\n\n```rust\nuse bgi::*;\n\nfn main() {\n    let mut driver = DETECT;\n    let mut mode = VGAHI;\n    \n    initgraph(\u0026mut driver, \u0026mut mode, \"\");\n    \n    if graphresult() != GraphResult::Ok {\n        eprintln!(\"Graphics initialization failed!\");\n        return;\n    }\n    \n    setcolor(Color::RED);\n    circle(320, 240, 50);\n    \n    outtextxy(250, 300, \"Press any key to exit\");\n    \n    getch();\n    closegraph();\n}\n```\n\nRun with visual output:\n```bash\ncargo run --example simple --features visual-backend\n```\n\n## Examples\n\n```bash\n# Basic drawing demo\ncargo run --example simple --features visual-backend\n\n# Mandelbrot set visualization\ncargo run --example mandelbrot --features visual-backend\n\n# Interactive demonstration with mouse/keyboard\ncargo run --example interactive_demo --features visual-backend\n\n# BGI compatibility test\ncargo run --example compatibility --features visual-backend\n\n# Batch rendering (optimized)\ncargo run --example mandelbrot_batched --features visual-backend\n```\n\n## API Overview\n\n### Graphics Initialization\n- `initgraph()` / `closegraph()` - Initialize and close graphics mode\n- `detectgraph()` - Auto-detect best graphics driver/mode\n- `getgraphmode()` / `setgraphmode()` - Get/set current mode\n- `graphresult()` / `grapherrormsg()` - Error handling\n\n### Drawing Primitives\n- `line()`, `lineto()`, `linerel()` - Line drawing\n- `circle()` - Circle with Bresenham algorithm\n- `arc()`, `ellipse()` - Arc and ellipse drawing\n- `rectangle()` - Rectangle outline\n- `putpixel()`, `getpixel()` - Pixel operations\n- `fillpoly()` - Polygon fill (outline only)\n\n### Colors \u0026 Palettes\n- `setcolor()`, `getcolor()` - Drawing color\n- `setbkcolor()`, `getbkcolor()` - Background color\n- `setpalette()`, `getpalette()` - Palette management\n- `setrgbpalette()` - RGB palette entry\n- 16 predefined colors: `Color::BLACK`, `Color::WHITE`, `Color::RED`, etc.\n\n### Line Styles \u0026 Fill\n- `setlinestyle()` - Solid, dashed, dotted, dot-dashed, user-defined patterns\n- `getlinesettings()` - Get current line style\n- `setfillstyle()` - Fill pattern and color\n- `setfillpattern()` - Custom 8x8 fill pattern\n- `setwritemode()` - COPY_PUT, XOR_PUT, OR_PUT, AND_PUT, NOT_PUT\n\n### Viewports \u0026 Coordinates\n- `setviewport()` / `getviewport()` - Clipping region\n- `clearviewport()` / `cleardevice()` - Screen clearing\n- `getmaxx()`, `getmaxy()` - Screen dimensions\n- `moveto()`, `moverel()`, `getx()`, `gety()` - Cursor control\n\n### Text (Partial)\n- `outtextxy()` - Display text at position (stub)\n- `settextstyle()`, `settextjustify()` - Text configuration\n- `textwidth()`, `textheight()` - Text measurement\n\n### Input Handling\n- `getch()`, `kbhit()` - Keyboard input\n- `getmouse()`, `ismouseclick()` - Mouse state\n- `mousex()`, `mousey()` - Mouse position\n- `setmouse()`, `clearmouseclick()` - Mouse control\n\n### Pages \u0026 Buffering\n- `setactivepage()` / `getactivepage()` - Draw to off-screen page\n- `setvisualpage()` / `getvisualpage()` - Display page\n\n### Utilities\n- `delay()` - Millisecond delay\n- `is_headless()` - Check if running without display\n- `set_batch_mode()`, `refresh()` - Batch rendering optimization\n\n### Optimizations\n- `BatchDrawer` - Batch multiple draw operations\n- `DrawingPool` - Pre-allocated buffers for repeated operations\n- `PatternShape\u003cN\u003e` - Compile-time optimized regular polygons\n\n## Supported Graphics Modes\n\n| Driver | Mode | Resolution | Colors |\n|--------|------|------------|--------|\n| CGA | CGAC0-CGAC3 | 320x200 | 4 |\n| CGA | CGAHI | 640x200 | 2 |\n| MCGA | MCGAC0-MCGAC3 | 320x200 | 256 |\n| MCGA | MCGAMED | 640x200 | 256 |\n| MCGA | MCGAHI | 640x480 | 256 |\n| EGA | EGALO | 640x200 | 16 |\n| EGA | EGAHI | 640x350 | 16 |\n| VGA | VGALO | 640x200 | 16 |\n| VGA | VGAMED | 640x350 | 16 |\n| VGA | VGAHI | 640x480 | 16 |\n\n## Backends\n\n### MiniFB Backend (`visual-backend` feature)\nCross-platform windowing using `minifb`. Provides real-time visual output with keyboard and mouse support.\n\n### Pixel Buffer Backend (default)\nHeadless backend for testing and offline rendering. Stores pixels in memory without display output.\n\n### PGM Backend (`pgm-backend` feature)\nOutputs to Portable GrayMap format files for image export.\n\n## Implementation Status\n\n**Complete:**\n- Graphics initialization and mode management\n- All drawing primitives (line, circle, arc, ellipse, rectangle)\n- Color and palette management\n- Line styles with custom patterns\n- Viewports and coordinate systems\n- Keyboard and mouse input\n- Page flipping / double buffering\n\n**Partial:**\n- Text rendering (outtextxy is a stub)\n- Fill patterns (outline only for polygons)\n- Image operations (getimage/putimage exist but limited)\n\n**Not Yet Implemented:**\n- Flood fill (`floodfill`)\n- Filled shapes (`bar`, `fillellipse`, `sector`, `pieslice`)\n- Font file loading\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fbgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunsided%2Fbgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fbgi/lists"}