Crate bevy_pixel_buffer
source ·Expand description
A bevy library to manage and draw a bunch of pixels.
Example
use bevy::prelude::*;
use bevy_pixel_buffer::prelude::*;
fn main() {
let size = PixelBufferSize {
size: UVec2::new(32, 32),
pixel_size: UVec2::new(16, 16),
};
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(PixelBufferPlugin)
.add_startup_system(pixel_buffer_setup(size))
.add_system(update)
.run()
}
fn update(mut pb: QueryPixelBuffer) {
pb.frame().per_pixel(|_, _| Pixel::random());
}
See other examples.
Quick how to
Create a pixel buffer
Probably PixelBufferBuilder is your friend, but if you like the more bevy like experience of working with bundles, see the bundle module.
Get the pixel buffer in your systems
There are 2 approaches:
- Create your custom bevy queries. A pixel buffer is composed of a
PixelBuffer, Handle
and optionally a EguiTexture and Handle components. - Use the premade queries in the query module. This exist for quick prototyping and common queries related to one or more pixel buffers.
Modify a pixel buffer
The data of the pixels lives inside a bevy Image. To edit it exists the Frame struct. There are many ways to get a Frame.
Once you have a Frame it offers methods to edit the Pixels. The crate does not offer drawing behaviour (yet) for shapes like triangles, quads or anything like that, but with Frame::raw_mut you can implement any behaviour you want.
Re-exports
pub use bevy_egui;
Modules
Utilities for constructing pixel buffers.
[Bundle]s that can be used to manually create a pixel buffer.
Adds a way to easily attach a compute shader to update the pixel buffer
every frame.
Adds integrations with bevy_egui and other [egui] types. This modules
requires the
egui
feature.Frame and frame utility functions that helps to draw things on raw image data.
Pixel struct with the ability to send it to the GPU.
Core systems and components of the pixel buffer library
Common imports
Adds utility queries