{"id":15137887,"url":"https://github.com/mintlu8/bevy_rectray","last_synced_at":"2025-10-23T13:30:52.475Z","repository":{"id":249341749,"uuid":"831250320","full_name":"mintlu8/bevy_rectray","owner":"mintlu8","description":"A minimal 2d layout system (that works in 3d!) for bevy.","archived":false,"fork":false,"pushed_at":"2024-12-01T06:39:46.000Z","size":499,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T18:48:21.430Z","etag":null,"topics":["bevy","layout","rust","ui"],"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/mintlu8.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-20T03:35:15.000Z","updated_at":"2024-12-01T06:39:50.000Z","dependencies_parsed_at":"2024-07-27T18:27:16.475Z","dependency_job_id":null,"html_url":"https://github.com/mintlu8/bevy_rectray","commit_stats":null,"previous_names":["mintlu8/bevy_rectray"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fbevy_rectray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fbevy_rectray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fbevy_rectray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fbevy_rectray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mintlu8","download_url":"https://codeload.github.com/mintlu8/bevy_rectray/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237834623,"owners_count":19373759,"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","layout","rust","ui"],"created_at":"2024-09-26T07:03:20.175Z","updated_at":"2025-10-23T13:30:52.455Z","avatar_url":"https://github.com/mintlu8.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bevy_rectray\n\nA minimal 2d layout system (that works in 3d!) for bevy.\n\n[![Crates.io](https://img.shields.io/crates/v/bevy_rectray.svg)](https://crates.io/crates/bevy_rectray)\n[![Docs](https://docs.rs/bevy_rectray/badge.svg)](https://docs.rs/bevy_rectray/latest/bevy_rectray/)\n[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://bevyengine.org/learn/book/plugin-development/)\n\n## Getting Started\n\nFirst add `RectrayPlugin`.\n\n```rust\napp.add_plugins(RectrayPlugin)\n```\n\nThen add `RectrayFrame` to a parent entity.\nThis effectively creates a 2d rectangular space around\nthe local `x` and `y` axis of the entity's `Transform`.\n\n```rust\ncommands.spawn(\n    SpacialBundle {\n        ...\n    },\n    RectrayFrame::from_dimension(Vec2::new(1024., 768.)),\n)\n```\n\nTo place descendant entities inside the frame, add `Transform2D` and `Dimension` next to entities\nwith `Transform`s.\n\n```rust\ncommands.spawn (\n    Transform { .. },\n    Transform2D { .. },\n    Dimension { .. },\n)\n```\n\nSince we only operate on `Transform`, `bevy_rectray`\nworks in `Transform - Transform2d - Transform` sandwich situations.\n\n## Integration\n\n`bevy_rectray` is minimal and does not magically react to changes in bevy components.\nWe take in `Transform2D` and `Dimension` and produces `Transform`\nand `RotatedRect`.\n\nSome of those data can come from external sources.\nFor example if you want to make all `Sprite`s take up space of its `Image` or `custom_size`,\nadd a system like this manually:\n\n```rust\npub fn update_sprite_dimension(\n    scaling_factor: Query\u003c\u0026Window, With\u003cPrimaryWindow\u003e\u003e,\n    mut query: Query\u003c(\u0026mut Sprite, \u0026Handle\u003cImage\u003e, \u0026mut Dimension)\u003e,\n    assets: Res\u003cAssets\u003cImage\u003e\u003e\n) {\n    let scaling_factor = scaling_factor\n         .get_single()\n         .map(|x| x.scale_factor())\n         .unwrap_or(1.0);\n    query.iter_mut().for_each(|(sp, im, mut dimension)| {\n        dimension.0 = sp.custom_size.or_else(|| {\n            sp.rect.map(|rect| (rect.max - rect.min) * scaling_factor)\n                .or_else(|| {\n                    assets.get(im)\n                        .map(|x|x.size().as_vec2() * scaling_factor)\n                })\n        }).unwrap_or(Vec2::ZERO)\n    })\n}\n```\n\nIf you want the opposite behavior, you can update the size of a sprite from\nthe outputted `RotatedRect::dimension`.\n\n## Containers\n\nAdd `RectrayContainerBundle` to put child items in a `Layout`.\nSee module level documentation for details.\n\n## Showcase\n\n* Place items on anchors of parents\n\n![anchors](./showcase/anchors.png)\n\n* Put 3d meshes in a layout\n\n![3d](./showcase/3d.png)\n\n* Place individual words to form a paragraph\n\n![text](./showcase/text.png)\n\n## Versions\n\n| bevy | bevy_rectray |\n|------|--------------|\n| 0.14 | 0.1          |\n| 0.15 | 0.2          |\n| 0.16 | 0.3-latest   |\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\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 dual licensed as above, without any\nadditional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintlu8%2Fbevy_rectray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmintlu8%2Fbevy_rectray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintlu8%2Fbevy_rectray/lists"}