{"id":33936503,"url":"https://github.com/kriogenia/bresenham_zip","last_synced_at":"2026-05-28T01:31:10.751Z","repository":{"id":42981093,"uuid":"465505366","full_name":"kriogenia/bresenham_zip","owner":"kriogenia","description":"Extension of the Bresenham algorithm to ease its use with triangles rasterization","archived":false,"fork":false,"pushed_at":"2022-03-24T23:38:59.000Z","size":47,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-14T02:10:03.912Z","etag":null,"topics":["algorithms","bresenham-algorithm","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/bresenham_zip/0.1.0","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kriogenia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-02T23:46:40.000Z","updated_at":"2022-03-04T23:21:53.000Z","dependencies_parsed_at":"2022-09-18T12:02:45.430Z","dependency_job_id":null,"html_url":"https://github.com/kriogenia/bresenham_zip","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kriogenia/bresenham_zip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Fbresenham_zip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Fbresenham_zip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Fbresenham_zip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Fbresenham_zip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kriogenia","download_url":"https://codeload.github.com/kriogenia/bresenham_zip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Fbresenham_zip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33590884,"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-05-27T02:00:06.184Z","response_time":53,"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":["algorithms","bresenham-algorithm","rust"],"created_at":"2025-12-12T14:18:22.154Z","updated_at":"2026-05-28T01:31:10.746Z","avatar_url":"https://github.com/kriogenia.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Crates.io](https://img.shields.io/crates/v/bresenham_zip)](https://crates.io/crates/bresenham_zip)\n[![docs.rs](https://img.shields.io/docsrs/bresenham_zip)](https://doc.rs/bresenham_zip)\n\n# Bresenham::zip\n\nThis library provides a wrapper to handle the simultaneous generation of two lines using [**Bresenham line algorithm**](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm).\nThis is something basic to implement [triangle rasterization](http://www.sunshine2k.de/coding/java/TriangleRasterization/TriangleRasterization.html)\nusing Bresenham. The wrapper works using the Bresenham algorithm of the [line drawing](https://crates.io/crates/line_drawing) crate. \n\nThe provided BresenhamZip iterator will provide two points of the same value in the specified axis at the same time conforming the \nlongest possible line between both. This way each tuple provided will contain the starting and ending point of each\nhorizontal or vertical line conforming the triangle.\n\nThis crate was born during the development of [FerruX Canvas](https://crates.io/crates/ferrux_canvas) to manage the\ngeneration of the points for the triangle filling function.\n\n## Usage\n\nBuild the BresenhamZip using the builders or the helper macro.\nYou will need to specify the axis to navigate and the three points of the triangle. \nThe last two of them must share the same value for X, Y or Z depending on which BresenhamZip you're using.\n\nThen iterate with the Zip with your method of choice. Each iteration will yield a pair of points defining the start and end of an horizontal or vertical line inside the triangle.\n\n```rust\n/// Rasterizes a 2D triangle with an horizontal base\nfor (left, right) in Builder::new().axis(bresenham_zip::Axis::Y)\n        .start_point((50, 50)).first_ending_point((0, 100)).second_ending_point((250, 100)).build()? {\n    draw_line(top, bottom); // draw_line is a figurative method, use one of your project\n    assert_eq!(left.1, right.1);\n    assert!((0..=50).contains(\u0026left.0));\n    assert!((50..=250).contains(\u0026right.0));\n }\n```\n\n```rust\n/// Rasterizes a 3D triangle using the helper macro\nfor (a, b) in build_zip!(3D:Z - (50, 50, 50) -\u003e (0, 10, 200), (100, 250, 200))? {\n    println!(\"{:?} - {:?}\", a, b);\n    assert_eq!(a.2, b.2);\n    assert!((0..=50).contains(\u0026a.0));\n    assert!((10..=50).contains(\u0026a.1));\n    assert!((50..=100).contains(\u0026b.0));\n    assert!((50..=250).contains(\u0026b.1));\n}\n```\n\n## License\n\nLicensed, at your option, under either of:\n\n* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))\n* MIT license ([LICENSE-MIT](LICENSE-MIT))\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkriogenia%2Fbresenham_zip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkriogenia%2Fbresenham_zip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkriogenia%2Fbresenham_zip/lists"}