Skip to main content

SpritesheetBuilder

Struct SpritesheetBuilder 

Source
pub struct SpritesheetBuilder {
    pub image: Option<Image>,
    pub shaders: Shaders,
    pub alpha_blending: AlphaBlending,
    pub minification_smoothing: bool,
    pub magnification_smoothing: bool,
    pub wrap: (TextureWrapping, TextureWrapping),
    pub srgb: bool,
}
Expand description

A builder for Spritesheet.

Fields§

§image: Option<Image>

The texture used when drawing with this handle. None can be used if you want to just draw flat-color quads.

§shaders: Shaders

The shaders used when drawing with this handle.

§alpha_blending: AlphaBlending

Whether to blend with previously drawn pixels when drawing over them, or just replace the color. Rule of thumb: if the sprites only use alpha values of 0 and 255 (ie. fully transparent and fully opaque), set this to false, and true otherwise. In any case, alpha values of less than 1/256 will be cut out and won’t be rendered at all.

Internally, this controls whether GL_BLEND and back-to-front sorting are enabled.

§minification_smoothing: bool

When drawing quads that are smaller than the texture provided, use linear (true) or nearest neighbor (false) smoothing when scaling? (Linear is probably always better.)

§magnification_smoothing: bool

When drawing quads that are larger than the texture provided, use linear (true) or nearest neighbor (false) smoothing when scaling? (Tip: for pixel art or other textures that don’t suffer from jaggies, set this to false for the intended look.)

§wrap: (TextureWrapping, TextureWrapping)

Sets the texture’s behavior when sampling coordinates under 0.0 or over 1.0, or smoothing over texture boundaries. (Corresponds to GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T, in that order.)

§srgb: bool

Controls whether the colors rendered by this draw call should be converted into sRGB before display. This should generally be true, unless you handle gamma in your shaders yourself. Note that in any case, the fragment shader will process fragments in linear space: this conversion happens after blending.

Internally, this controls whether or not GL_FRAMEBUFFER_SRGB is enabled when drawing with this handle.

Implementations§

Source§

impl SpritesheetBuilder

Source

pub fn build(&self, ctx: &mut Context) -> Spritesheet

Creates a new Spritesheet from this builder.

Source

pub fn image(&mut self, image: Image) -> &mut SpritesheetBuilder

Sets the spritesheet’s texture.

Source

pub fn shaders(&mut self, shaders: Shaders) -> &mut SpritesheetBuilder

Sets the spritesheet’s shaders.

Source

pub fn alpha_blending( &mut self, blend: bool, sort: bool, ) -> &mut SpritesheetBuilder

Toggles the spritesheet’s alpha blending.

Source

pub fn minification_smoothing( &mut self, smoothing: bool, ) -> &mut SpritesheetBuilder

Sets the spritesheet’s minification filter.

Source

pub fn magnification_smoothing( &mut self, smoothing: bool, ) -> &mut SpritesheetBuilder

Sets the spritesheet’s magnification filter.

Source

pub fn wrapping_behavior( &mut self, wrap_s: TextureWrapping, wrap_t: TextureWrapping, ) -> &mut SpritesheetBuilder

Sets the spritesheet texture’s wrapping behavior.

Source

pub fn srgb(&mut self, srgb: bool) -> &mut SpritesheetBuilder

Toggles the srgb-ness of the draw call.

Trait Implementations§

Source§

impl Clone for SpritesheetBuilder

Source§

fn clone(&self) -> SpritesheetBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SpritesheetBuilder

Source§

fn default() -> SpritesheetBuilder

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.