{"id":26924359,"url":"https://github.com/amamic1803/tinydraw-rs","last_synced_at":"2025-04-02T01:53:58.746Z","repository":{"id":65926919,"uuid":"597155878","full_name":"amamic1803/tinydraw-rs","owner":"amamic1803","description":"A small 2D drawing library in Rust","archived":false,"fork":false,"pushed_at":"2024-05-07T15:23:44.000Z","size":169,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-10T23:15:10.512Z","etag":null,"topics":["antialiasing","crates-io","drawing","image","rust-crate","rust-lang","shapes"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amamic1803.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-02-03T18:50:41.000Z","updated_at":"2024-05-07T15:23:48.000Z","dependencies_parsed_at":"2023-09-26T23:14:37.469Z","dependency_job_id":"541d4a6b-ec9b-4fb9-a8ce-45e385c55cb4","html_url":"https://github.com/amamic1803/tinydraw-rs","commit_stats":null,"previous_names":["amamic1803/tinydraw-rs","darklord76865/tinydraw-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amamic1803%2Ftinydraw-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amamic1803%2Ftinydraw-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amamic1803%2Ftinydraw-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amamic1803%2Ftinydraw-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amamic1803","download_url":"https://codeload.github.com/amamic1803/tinydraw-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246741123,"owners_count":20826064,"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":["antialiasing","crates-io","drawing","image","rust-crate","rust-lang","shapes"],"created_at":"2025-04-02T01:53:58.662Z","updated_at":"2025-04-02T01:53:58.736Z","avatar_url":"https://github.com/amamic1803.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tinydraw-rs\n\n**tinydraw** is a small library for 2D drawing in Rust\n\n---\n\nIt's a simple crate used for drawing basic, anti-aliased shapes onto images, written in pure Rust. \nSupport for reading and exporting images as PNG or bytes is included ([dependencies](#dependencies)).\n\n\n[**Documentation**](https://docs.rs/tinydraw/latest/tinydraw/ \"docs.rs\")\n\n[**Crate**](https://crates.io/crates/tinydraw \"crates.io\")\n\n### Available Shapes\n- line\n- rectangle\n- circle\n- ellipse\n\n### Example\n```rust\nuse tinydraw::ImageRGB8;\n\nfn main() { \n    let background_color: [u8; 3] = [255, 155, 0];\n    let mut image: ImageRGB8 = ImageRGB8::new(640, 360, background_color);\n  \n    image.draw_line(0, 0, 639, 359, [255, 255, 255], 1, 1.0);\n    image.draw_line(0, 359, 639, 0, [255, 255, 255], 1, 1.0);\n    image.draw_rectangle(0, 0, 639, 359, [255, 255, 255], 3, 1.0);\n    image.draw_ellipse(319, 179, 300, 150, [0, 0, 0], 0, 0.5);\n    image.draw_circle(149, 179, 30, [255, 255, 255], 0, 1.0);\n    image.draw_circle(149, 179, 20, [0, 0, 0], 0, 1.0);\n    image.draw_circle(489, 179, 30, [255, 255, 255], 0, 1.0);\n    image.draw_circle(489, 179, 20, [0, 0, 0], 0, 1.0);\n    image.draw_ellipse(319, 90, 80, 30, [255, 255, 255], 0, 1.0);\n    image.draw_ellipse(319, 90, 60, 20, [0, 0, 0], 0, 1.0);\n  \n    image.to_png(\"image.png\").unwrap();\n}\n```\nThis code generates the following image:\n\n![image](https://user-images.githubusercontent.com/40371578/219385956-1691f210-7197-4b5e-94aa-ed76ac84787e.png)\n\n### Limitations\n- thickness above 1 doesn't work for:\n  - line\n  - circle\n  - ellipse\n- coordinates exceeding the image bounds don't work for:\n  - rectangle\n  - circle\n  - ellipse\n- only RGB images with bit depth of 8 are currently supported\n\n## Dependencies\n[bytemuck](https://crates.io/crates/bytemuck) (reading, exporting bytes)\n\n[png](https://crates.io/crates/png) (reading, exporting PNG)\n\n## Development\nI intend to fix the limitations and perhaps add more shapes in the future.\nIt depends on my free time and whether there will be any interest for this crate.\nIf you encounter a bug or have any suggestions, feel free to open an issue.\nIf you want to contribute, feel free to open a pull request.\n\n## References\n[Wikipedia - Xiaolin Wu's line algorithm](https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm)\n\n[GeeksforGeeks - Anti-aliased Line | Xiaolin Wu’s algorithm](https://www.geeksforgeeks.org/anti-aliased-line-xiaolin-wus-algorithm/)\n\n[Stephan Brumme - Drawing Antialiased Circles and Ellipses](https://create.stephan-brumme.com/antialiased-circle/)\n\n[David Moksha - Fast, Antialiased Circles and Ellipses from Xiaolin Wu’s concepts](https://yellowsplash.wordpress.com/2009/10/23/fast-antialiased-circles-and-ellipses-from-xiaolin-wus-concepts/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famamic1803%2Ftinydraw-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famamic1803%2Ftinydraw-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famamic1803%2Ftinydraw-rs/lists"}