{"id":15687178,"url":"https://github.com/shnewto/edges","last_synced_at":"2025-04-16T03:48:26.437Z","repository":{"id":225453516,"uuid":"765970695","full_name":"shnewto/edges","owner":"shnewto","description":"get the edges of objects in images","archived":false,"fork":false,"pushed_at":"2025-02-04T17:36:47.000Z","size":115,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T05:58:44.267Z","etag":null,"topics":["bevy","collider","colliders","edges","image","images","rust","sprite","sprites","transparency"],"latest_commit_sha":null,"homepage":"","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/shnewto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2024-03-02T01:46:02.000Z","updated_at":"2025-01-12T17:26:09.000Z","dependencies_parsed_at":"2024-12-08T11:24:25.421Z","dependency_job_id":"af4b73d5-0acc-4269-8286-62d1b63c3095","html_url":"https://github.com/shnewto/edges","commit_stats":{"total_commits":30,"total_committers":8,"mean_commits":3.75,"dds":"0.23333333333333328","last_synced_commit":"679be82469e4829ec78324d7f9e13bf2edd4b13e"},"previous_names":["shnewto/edges"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shnewto%2Fedges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shnewto%2Fedges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shnewto%2Fedges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shnewto%2Fedges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shnewto","download_url":"https://codeload.github.com/shnewto/edges/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249192410,"owners_count":21227781,"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":["bevy","collider","colliders","edges","image","images","rust","sprite","sprites","transparency"],"created_at":"2024-10-03T17:44:39.234Z","updated_at":"2025-04-16T03:48:26.406Z","avatar_url":"https://github.com/shnewto.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# edges\n\n[![Crates.io](https://img.shields.io/crates/v/edges.svg)](https://crates.io/crates/edges)\n[![Crates.io](https://img.shields.io/crates/d/edges.svg)](https://crates.io/crates/edges)\n[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/shnewto/edges#license)\n\nGet the edges of objects in images with transparency.\n\n## Supported image types\n\n- `image::DynamicImage`\n- `bevy::image::Image` (or if you rather, `bevy::prelude::Image`)\n\n## Using\n\n```rust\nuse edges::Edges;\nuse std::path::Path;\n\nlet image = image::open(Path::new(\"assets/car.png\"));\nlet edges = Edges::from(image.unwrap());\nprintln!(\"{:#?}\", edges.single_translated());\n```\n\n## How it works\n\nI was inspired by [a coding train (or, coding in the cabana rather)\non an implementation of \"marching squares\"](https://youtu.be/0ZONMNUKTfU).\nSo this crate takes a \"march through all the values\" approach to find edges, i.e.\npixels with at least 1 empty neighboring pixel, but\ninstead of drawing a contour in place,\nit just keeps track of all the actual pixel coordinates. To determine \"empty\" I bitwise\nor all the bytes for each pixel and,\nin images with transparency, \"empty\" is a zero value for the pixel.\n\nAfter that, we need to put the coordinates in some kind of\n\"drawing order\" so whatever we pass all the points to,\nknows how we want the object constructed. For this, the\ncrate collects all pixels, in order, that are a distance of 1 from each other.\nIf there are pixels that have a distance greater than 1\nfrom any pixel in an existing group, that pixel begins a new group.\n\n## License\n\nAll code in this repository is dual-licensed under either:\n\n- MIT License (LICENSE-MIT or \u003chttp://opensource.org/licenses/MIT\u003e)\n- Apache License, Version 2.0 (LICENSE-APACHE or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n\nAt your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshnewto%2Fedges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshnewto%2Fedges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshnewto%2Fedges/lists"}