Struct PixelBuffer

Source
pub struct PixelBuffer { /* private fields */ }
Expand description

Array of pixels resource that can be written to from the RenderSystem system.

use specs::prelude::*;
use specs_blit::PixelBuffer;

const WIDTH: usize = 800;
const HEIGHT: usize = 800;

// Setup the specs world
let mut world = World::new();

// Add the pixel buffer as a resource so it can be accessed from the RenderSystem later
world.insert(PixelBuffer::new(WIDTH, HEIGHT));

Implementations§

Source§

impl PixelBuffer

Source

pub fn new(width: usize, height: usize) -> Self

Create a new buffer filled with black pixels.

Source

pub fn pixels(&self) -> &Vec<u32>

Get the array of pixels.

Source

pub fn pixels_mut(&mut self) -> &mut Vec<u32>

Get the array so that it can be mutated manually.

Source

pub fn width(&self) -> usize

Get the width in pixels.

Source

pub fn height(&self) -> usize

Get the height in pixels.

Source

pub fn clear(&mut self, color: u32)

Set all the pixels to the passed color.

Trait Implementations§

Source§

impl Debug for PixelBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PixelBuffer

Source§

fn default() -> PixelBuffer

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<T> TryDefault for T
where T: Default,

Source§

fn try_default() -> Result<T, String>

Tries to create the default.
Source§

fn unwrap_default() -> Self

Calls try_default and panics on an error case.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Event for T
where T: Send + Sync + 'static,

Source§

impl<T> Resource for T
where T: Any + Send + Sync,