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
impl FlyweightContext
sourcepub fn new(
offset_x_to_image: usize,
image_width: usize,
image_height: usize
) -> FlyweightContext
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.