Rustdoc examples for OrthographicProjection (#11031)

Minimal working examples are helpful.

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
Stepan Koltsov 2024-01-09 00:08:58 +00:00 committed by GitHub
parent cf3105a0db
commit 9813e39f90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -193,6 +193,19 @@ impl Default for PerspectiveProjection {
}
}
/// Scaling mode for [`OrthographicProjection`].
///
/// # Examples
///
/// Configure the orthographic projection to two world units per window height:
///
/// ```
/// # use bevy_render::camera::{OrthographicProjection, Projection, ScalingMode};
/// let projection = Projection::Orthographic(OrthographicProjection {
/// scaling_mode: ScalingMode::FixedVertical(2.0),
/// ..OrthographicProjection::default()
/// });
/// ```
#[derive(Debug, Clone, Copy, Reflect, Serialize, Deserialize)]
#[reflect(Serialize, Deserialize)]
pub enum ScalingMode {
@ -278,6 +291,18 @@ impl DivAssign<f32> for ScalingMode {
///
/// Note that the scale of the projection and the apparent size of objects are inversely proportional.
/// As the size of the projection increases, the size of objects decreases.
///
/// # Examples
///
/// Configure the orthographic projection to one world unit per 100 window pixels:
///
/// ```
/// # use bevy_render::camera::{OrthographicProjection, Projection, ScalingMode};
/// let projection = Projection::Orthographic(OrthographicProjection {
/// scaling_mode: ScalingMode::WindowSize(100.0),
/// ..OrthographicProjection::default()
/// });
/// ```
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)]
pub struct OrthographicProjection {