pub struct Camera {
    pub offset: Vec2,
    pub scale: f32,
    /* private fields */
}
Expand description

2D camera that can be controlled by mouse. Offset and scale can be changed.

Note: You can get a Camera2D using `let cam2d: Camera2D = (&cam).into();

Fields

offset: Vec2scale: f32

Implementations

If wheel_value has positive value, scale cam around point center by factor scale_factor. If wheel_value is negative, then scale by 1.0/scale_factor. If wheel_value equals 0.0 or scale_factor equals 1.0, nothing happens.

Adds mul_to_scale to current scale of cam. Scale is changed around point center.

Replace current scale of camera with new_scale. Scale is changed around point center.

Update camera position by new mouse position. This method must be run at every frame. should_offset controls if the camera should actually move or not.

Note: It’s better to use mouse_position_local with this method, otherwise if you use mouse_position the movement is way too big.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Converts this type into the (usually inferred) input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.