Skip to main content

Frame

Struct Frame 

Source
pub struct Frame<'a> { /* private fields */ }
Expand description

One frame of drawing into a SoftwareRenderer’s surface, from SoftwareRenderer::begin_frame.

Draw calls rasterize immediately, in call order, each blended over what is already there. See the crate documentation for coordinates, sampling, and blending.

Implementations§

Source§

impl Frame<'_>

Source

pub const fn width(&self) -> usize

Surface width in pixels.

Source

pub const fn height(&self) -> usize

Surface height in pixels.

Source

pub const fn surface(&self) -> &SoftwareSurface

The pixels drawn so far.

Source

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

Overwrites every pixel with color, without blending.

Source

pub fn fill_rect( &mut self, rect: Rect, color: Color, clip: ClipRect, ) -> Result<(), Error>

Blends a solid rectangle over the surface.

A pixel is covered when its center lies in rect: min < center <= max on each axis. A rectangle with max <= min on either axis covers nothing.

§Errors

Error::NonFiniteRect if a coordinate is NaN or infinite.

Source

pub fn textured_rect( &mut self, rect: Rect, uv: Rect, texture: TextureId, tint: Color, clip: ClipRect, ) -> Result<(), Error>

Blends texture over rect, mapping uv.min to the rectangle’s top-left corner and uv.max to its bottom-right, each texel multiplied by the premultiplied tint (Color::WHITE leaves it unchanged). Coverage is as in Frame::fill_rect.

§Errors

Error::NonFiniteRect for a NaN or infinite coordinate in rect or uv, and Error::UnknownTexture for a freed or foreign texture.

Source

pub fn mesh(&mut self, mesh: Mesh<'_>, clip: ClipRect) -> Result<(), Error>

Blends a triangle mesh over the surface.

A pixel is covered when its center falls inside a triangle. Centers exactly on an edge go to one side by a fixed tie-break, so triangles sharing an edge never both blend a pixel on it. Colors interpolate across each triangle; texels are sampled nearest-neighbor.

§Errors

Error::IndexCount if the index count is not a multiple of three, Error::IndexOutOfRange for an index past the vertices, Error::NonFiniteVertex for a NaN or infinite position or texture coordinate on any vertex, referenced or not, and Error::UnknownTexture for a freed or foreign texture.

Trait Implementations§

Source§

impl<'a> Debug for Frame<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Frame<'a>

§

impl<'a> !UnwindSafe for Frame<'a>

§

impl<'a> Freeze for Frame<'a>

§

impl<'a> Send for Frame<'a>

§

impl<'a> Sync for Frame<'a>

§

impl<'a> Unpin for Frame<'a>

§

impl<'a> UnsafeUnpin for Frame<'a>

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.