{"id":17939770,"url":"https://github.com/shanecelis/bevy_mod_plotters","last_synced_at":"2025-08-15T18:32:51.704Z","repository":{"id":259820255,"uuid":"879122985","full_name":"shanecelis/bevy_mod_plotters","owner":"shanecelis","description":"A plotter material for bevy","archived":false,"fork":false,"pushed_at":"2024-10-29T00:13:18.000Z","size":85,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-16T18:43:51.985Z","etag":null,"topics":["bevy","plot","shader"],"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/shanecelis.png","metadata":{"files":{"readme":"README.md","changelog":null,"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},"funding":{"github":"shanecelis"}},"created_at":"2024-10-27T03:30:55.000Z","updated_at":"2024-10-29T12:58:35.000Z","dependencies_parsed_at":"2024-10-28T06:55:32.172Z","dependency_job_id":"36ad0ebb-ac6a-4c8b-8da5-fbd7758573f3","html_url":"https://github.com/shanecelis/bevy_mod_plotters","commit_stats":null,"previous_names":["shanecelis/bevy_mod_plotters"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shanecelis%2Fbevy_mod_plotters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shanecelis%2Fbevy_mod_plotters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shanecelis%2Fbevy_mod_plotters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shanecelis%2Fbevy_mod_plotters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shanecelis","download_url":"https://codeload.github.com/shanecelis/bevy_mod_plotters/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229941340,"owners_count":18148269,"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","plot","shader"],"created_at":"2024-10-29T00:44:09.028Z","updated_at":"2024-12-16T09:55:58.625Z","avatar_url":"https://github.com/shanecelis.png","language":"Rust","funding_links":["https://github.com/sponsors/shanecelis"],"categories":[],"sub_categories":[],"readme":"# bevy_mod_plotters\n![Maintenance](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg)\n[![CI](https://github.com/shanecelis/bevy_mod_plotters/actions/workflows/rust.yml/badge.svg)](https://github.com/shanecelis/bevy_mod_plotters/actions)\n  [![crates-io](https://img.shields.io/crates/v/bevy_mod_plotters.svg)](https://crates.io/crates/bevy_mod_plotters)\n  [![api-docs](https://docs.rs/bevy_mod_plotters/badge.svg)](https://docs.rs/bevy_mod_plotters)\n\nA [bevy game engine](https://bevyengine.org) material to display the [plotters](https://github.com/plotters-rs/plotters) BGRX texture format.\n\n![Example anim_graph of sine wave.](https://github.com/user-attachments/assets/4c953a1b-a95a-4b72-8d18-efdeab4b79b9)\n\n# Motivation\n\nThe BGRX texture used by plotters is like a BGRA texture, but the plotters crate\ndoes not does not abstain from overwriting the 'X' byte, which for BGRA is the\nalpha channel, so one cannot rely on setting alpha once in the texture data but\nmust assume it was changed after any render from plotters. This crate exists\nprincipally to avoid that alpha resetting problem and provide convenience\nmethods.\n\n# Install\n\nInstall the crate.\n\n```sh\ncargo add bevy_mod_plotters\n```\n\n# Usage\n\n## Add Plugin to App\n\n```rust,no_run\nuse bevy::prelude::*;\n\nfn main() {\n    App::new()\n        .add_plugins(bevy_mod_plotters::PlottersPlugin)\n        .run();\n}\n```\n\n## Create Image and Plot\n\n``` rust,no_run\n# use bevy::{\n#     prelude::*,\n#     render::{\n#         render_asset::RenderAssetUsages,\n#         render_resource::{Extent3d, TextureDimension, TextureFormat},\n#         texture::Image,\n#     },\n# };\n# use plotters::coord::Shift;\nuse bevy_mod_plotters::prelude::*;\nuse plotters::prelude::*;\nfn setup() -\u003e Image {\n    let mut image = Image::new_fill(\n        Extent3d {\n            width: 500,\n            height: 500,\n            depth_or_array_layers: 1,\n        },\n        TextureDimension::D2,\n        \u0026[0x00, 0x00, 0x00, 0x00],\n        TextureFormat::Bgra8UnormSrgb,\n        RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD,\n    );\n    \n    {\n        let root = try_as_backend(\u0026mut image)\n            .unwrap()\n            .into_drawing_area();\n        plot(\u0026root)\n            .unwrap();\n    }\n    image\n}\n\nfn plot\u003cDB: DrawingBackend\u003e(\n    root: \u0026DrawingArea\u003cDB, Shift\u003e,\n) -\u003e Result\u003c(), DrawingAreaErrorKind\u003cDB::ErrorType\u003e\u003e {\n\n    let mut chart = ChartBuilder::on(\u0026root)\n        .caption(\"Hello, World!\", (\"sans-serif\", 40).into_font())\n        .build_cartesian_2d(-1.0..1.0, -1.0..1.0)?;\n\n    let points = vec![(0.0, 0.0), (5.0, 5.0), (8.0, 7.0)];\n    chart.draw_series(LineSeries::new(points, \u0026RED))?;\n    root.present()\n}\n```\n\n## Add Image as a `PlotUiMaterial`\n\n```rust,compile\n# use bevy::{\n#     prelude::*,\n#     color::palettes::basic,\n#     pbr::ExtendedMaterial,\n# };\n# use bevy_mod_plotters::*;\nfn add_image(\n    In(image): In\u003cImage\u003e,\n    mut commands: Commands,\n    mut images: ResMut\u003cAssets\u003cImage\u003e\u003e,\n    mut ui_materials: ResMut\u003cAssets\u003cPlotUiMaterial\u003e\u003e,\n) {\n    commands.spawn(Camera2dBundle::default());\n    commands\n        .spawn(NodeBundle {\n            style: Style {\n                width: Val::Percent(100.),\n                height: Val::Percent(100.),\n                justify_content: JustifyContent::Center,\n                ..Default::default()\n            },\n            ..Default::default()\n        })\n        .with_children(|parent| {\n            parent.spawn(MaterialNodeBundle {\n                style: Style {\n                    width: Val::Px(500.0),\n                    height: Val::Px(500.0),\n                    border: UiRect::all(Val::Px(20.0)),\n                    ..default()\n                },\n                material: ui_materials.add(PlotUiMaterial {\n                    color: LinearRgba::WHITE,\n                    texture: images.add(image),\n                }),\n                ..default()\n            });\n        });\n}\n```\n\n# Examples\n\nRun the \"draw_graph\" example like so:\n\n```sh\ncargo run --example draw_graph\n```\n\nThis will show a plot of three points and a red line.\n\n* `draw_graph` - Plot three points and a line; hit 'Space' to update.\n* `anim_graph` - Animate a sinusoidal wave.\n\n# TODO\n\nConsider adding a plotters backend specifically for the BGRA8 formats that will\nnot overwrite the alpha channel. A backend like that might be slightly slower for writing, but it would allow one to produce plots with a transparent background.\n\n# Compatibility\n\n| bevy_mod_plotters | bevy |\n|-------------------|------|\n| 0.1               | 0.14 |\n\n# License\n\nThis crate is licensed under the MIT License or the Apache License 2.0. The\nexamples are licensed under the CC0 license.\n\n# Acknowlegments\n\n* Thanks to [Claire V. Hammond](https://github.com/cvhammond) for the [bevy_plotters_test](https://github.com/cvhammond/bevy_plotters_test) repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshanecelis%2Fbevy_mod_plotters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshanecelis%2Fbevy_mod_plotters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshanecelis%2Fbevy_mod_plotters/lists"}