pub struct FlyweightContext {
    pub offset_x_to_image: usize,
    pub image_width: usize,
    pub image_height: usize,
    pub position_x: f32,
    pub position_y: f32,
    pub velocity_x: f32,
    pub velocity_y: f32,
}
Expand description

Represents the context for an instance of the Flyweight_Image structure. In this case, the context includes position and velocity.

This context is manipulated outside the Flyweight Image by the controlling entity (in this case, the flyweight_exercise() function). The FlyweightImage struct just holds onto the context, along with a handle to the big resource.

Fields§

§offset_x_to_image: usize

Offset into big resource to left edge of image, in characters.

§image_width: usize

Width of image, in characters

§image_height: usize

Height of image, in characters

§position_x: f32

Horizontal position of upper left corner of image in a display, in characters

§position_y: f32

Vertical position of upper left corner of image in a display, in characters

§velocity_x: f32

Velocity to apply to the horizontal position, in fractions of a character

§velocity_y: f32

Velocity to apply to the vertical position, in fractions of a character

Implementations§

source§

impl FlyweightContext

source

pub fn new( offset_x_to_image: usize, image_width: usize, image_height: usize ) -> FlyweightContext

Constructor.

Parameters
  • offset_x_to_image

    Offset into big resource to left edge of image, in characters.

  • image_width

    Width of image, in characters.

  • image_height

    Height of image, in characters.

Returns

Returns a new instance of the FlyweightContext struct.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V