Struct LinearRgba

Source
#[repr(C)]
pub struct LinearRgba { pub red: f32, pub green: f32, pub blue: f32, pub alpha: f32, }
Expand description

Linear RGB color with alpha.

§Conversion

Conversion between the various color spaces is achieved using Rust’s native From trait. Because certain color spaces are defined by their transformation to and from another space, these From implementations reflect that set of definitions.

let color = Srgba::rgb(0.5, 0.5, 0.5);

// Using From explicitly
let linear_color = LinearRgba::from(color);

// Using Into
let linear_color: LinearRgba = color.into();

For example, the sRGB space is defined by its relationship with Linear RGB, and HWB by its with sRGB. As such, it is the responsibility of sRGB to provide From implementations for Linear RGB, and HWB for sRGB. To then provide conversion between Linear RGB and HWB directly, HWB is responsible for implementing these conversions, delegating to sRGB as an intermediatory. This ensures that all conversions take the shortest path between any two spaces, and limit the proliferation of domain specific knowledge for each color space to their respective definitions.

GPU

Fields§

§red: f32

The red channel. [0.0, 1.0]

§green: f32

The green channel. [0.0, 1.0]

§blue: f32

The blue channel. [0.0, 1.0]

§alpha: f32

The alpha channel. [0.0, 1.0]

Implementations§

Source§

impl LinearRgba

Source

pub const BLACK: LinearRgba

A fully black color with full alpha.

Source

pub const WHITE: LinearRgba

A fully white color with full alpha.

Source

pub const NONE: LinearRgba

A fully transparent color.

Source

pub const RED: LinearRgba

A fully red color with full alpha.

Source

pub const GREEN: LinearRgba

A fully green color with full alpha.

Source

pub const BLUE: LinearRgba

A fully blue color with full alpha.

Source

pub const NAN: LinearRgba

An invalid color.

This type can be used to represent an invalid color value; in some rendering applications the color will be ignored, enabling performant hacks like hiding lines by setting their color to INVALID.

Source

pub const fn new(red: f32, green: f32, blue: f32, alpha: f32) -> LinearRgba

Construct a new LinearRgba color from components.

Examples found in repository?
examples/3d/spotlight.rs (line 77)
37fn setup(
38    mut commands: Commands,
39    mut meshes: ResMut<Assets<Mesh>>,
40    mut materials: ResMut<Assets<StandardMaterial>>,
41) {
42    // ground plane
43    commands.spawn((
44        Mesh3d(meshes.add(Plane3d::default().mesh().size(100.0, 100.0))),
45        MeshMaterial3d(materials.add(Color::WHITE)),
46        Movable,
47    ));
48
49    // cubes
50
51    // We're seeding the PRNG here to make this example deterministic for testing purposes.
52    // This isn't strictly required in practical use unless you need your app to be deterministic.
53    let mut rng = ChaCha8Rng::seed_from_u64(19878367467713);
54    let cube_mesh = meshes.add(Cuboid::new(0.5, 0.5, 0.5));
55    let blue = materials.add(Color::srgb_u8(124, 144, 255));
56
57    commands.spawn_batch(
58        std::iter::repeat_with(move || {
59            let x = rng.gen_range(-5.0..5.0);
60            let y = rng.gen_range(0.0..3.0);
61            let z = rng.gen_range(-5.0..5.0);
62
63            (
64                Mesh3d(cube_mesh.clone()),
65                MeshMaterial3d(blue.clone()),
66                Transform::from_xyz(x, y, z),
67                Movable,
68            )
69        })
70        .take(40),
71    );
72
73    let sphere_mesh = meshes.add(Sphere::new(0.05).mesh().uv(32, 18));
74    let sphere_mesh_direction = meshes.add(Sphere::new(0.1).mesh().uv(32, 18));
75    let red_emissive = materials.add(StandardMaterial {
76        base_color: RED.into(),
77        emissive: LinearRgba::new(1.0, 0.0, 0.0, 0.0),
78        ..default()
79    });
80    let maroon_emissive = materials.add(StandardMaterial {
81        base_color: MAROON.into(),
82        emissive: LinearRgba::new(0.369, 0.0, 0.0, 0.0),
83        ..default()
84    });
85
86    for x in 0..4 {
87        for z in 0..4 {
88            let x = x as f32 - 2.0;
89            let z = z as f32 - 2.0;
90            // red spot_light
91            commands
92                .spawn((
93                    SpotLight {
94                        intensity: 40_000.0, // lumens
95                        color: Color::WHITE,
96                        shadows_enabled: true,
97                        inner_angle: PI / 4.0 * 0.85,
98                        outer_angle: PI / 4.0,
99                        ..default()
100                    },
101                    Transform::from_xyz(1.0 + x, 2.0, z)
102                        .looking_at(Vec3::new(1.0 + x, 0.0, z), Vec3::X),
103                ))
104                .with_children(|builder| {
105                    builder.spawn((
106                        Mesh3d(sphere_mesh.clone()),
107                        MeshMaterial3d(red_emissive.clone()),
108                    ));
109                    builder.spawn((
110                        Mesh3d(sphere_mesh_direction.clone()),
111                        MeshMaterial3d(maroon_emissive.clone()),
112                        Transform::from_translation(Vec3::Z * -0.1),
113                        NotShadowCaster,
114                    ));
115                });
116        }
117    }
118
119    // camera
120    commands.spawn((
121        Camera3d::default(),
122        Camera {
123            hdr: true,
124            ..default()
125        },
126        Transform::from_xyz(-4.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
127    ));
128
129    commands.spawn((
130        Text::new(INSTRUCTIONS),
131        Node {
132            position_type: PositionType::Absolute,
133            top: Val::Px(12.0),
134            left: Val::Px(12.0),
135            ..default()
136        },
137    ));
138}
More examples
Hide additional examples
examples/3d/lighting.rs (line 133)
34fn setup(
35    parameters: Res<Parameters>,
36    mut commands: Commands,
37    mut meshes: ResMut<Assets<Mesh>>,
38    mut materials: ResMut<Assets<StandardMaterial>>,
39    asset_server: Res<AssetServer>,
40) {
41    // ground plane
42    commands.spawn((
43        Mesh3d(meshes.add(Plane3d::default().mesh().size(10.0, 10.0))),
44        MeshMaterial3d(materials.add(StandardMaterial {
45            base_color: Color::WHITE,
46            perceptual_roughness: 1.0,
47            ..default()
48        })),
49    ));
50
51    // left wall
52    let mut transform = Transform::from_xyz(2.5, 2.5, 0.0);
53    transform.rotate_z(PI / 2.);
54    commands.spawn((
55        Mesh3d(meshes.add(Cuboid::new(5.0, 0.15, 5.0))),
56        MeshMaterial3d(materials.add(StandardMaterial {
57            base_color: INDIGO.into(),
58            perceptual_roughness: 1.0,
59            ..default()
60        })),
61        transform,
62    ));
63    // back (right) wall
64    let mut transform = Transform::from_xyz(0.0, 2.5, -2.5);
65    transform.rotate_x(PI / 2.);
66    commands.spawn((
67        Mesh3d(meshes.add(Cuboid::new(5.0, 0.15, 5.0))),
68        MeshMaterial3d(materials.add(StandardMaterial {
69            base_color: INDIGO.into(),
70            perceptual_roughness: 1.0,
71            ..default()
72        })),
73        transform,
74    ));
75
76    // Bevy logo to demonstrate alpha mask shadows
77    let mut transform = Transform::from_xyz(-2.2, 0.5, 1.0);
78    transform.rotate_y(PI / 8.);
79    commands.spawn((
80        Mesh3d(meshes.add(Rectangle::new(2.0, 0.5))),
81        MeshMaterial3d(materials.add(StandardMaterial {
82            base_color_texture: Some(asset_server.load("branding/bevy_logo_light.png")),
83            perceptual_roughness: 1.0,
84            alpha_mode: AlphaMode::Mask(0.5),
85            cull_mode: None,
86            ..default()
87        })),
88        transform,
89        Movable,
90    ));
91
92    // cube
93    commands.spawn((
94        Mesh3d(meshes.add(Cuboid::default())),
95        MeshMaterial3d(materials.add(StandardMaterial {
96            base_color: DEEP_PINK.into(),
97            ..default()
98        })),
99        Transform::from_xyz(0.0, 0.5, 0.0),
100        Movable,
101    ));
102    // sphere
103    commands.spawn((
104        Mesh3d(meshes.add(Sphere::new(0.5).mesh().uv(32, 18))),
105        MeshMaterial3d(materials.add(StandardMaterial {
106            base_color: LIMEGREEN.into(),
107            ..default()
108        })),
109        Transform::from_xyz(1.5, 1.0, 1.5),
110        Movable,
111    ));
112
113    // ambient light
114    commands.insert_resource(AmbientLight {
115        color: ORANGE_RED.into(),
116        brightness: 0.02,
117        ..default()
118    });
119
120    // red point light
121    commands.spawn((
122        PointLight {
123            intensity: 100_000.0,
124            color: RED.into(),
125            shadows_enabled: true,
126            ..default()
127        },
128        Transform::from_xyz(1.0, 2.0, 0.0),
129        children![(
130            Mesh3d(meshes.add(Sphere::new(0.1).mesh().uv(32, 18))),
131            MeshMaterial3d(materials.add(StandardMaterial {
132                base_color: RED.into(),
133                emissive: LinearRgba::new(4.0, 0.0, 0.0, 0.0),
134                ..default()
135            })),
136        )],
137    ));
138
139    // green spot light
140    commands.spawn((
141        SpotLight {
142            intensity: 100_000.0,
143            color: LIME.into(),
144            shadows_enabled: true,
145            inner_angle: 0.6,
146            outer_angle: 0.8,
147            ..default()
148        },
149        Transform::from_xyz(-1.0, 2.0, 0.0).looking_at(Vec3::new(-1.0, 0.0, 0.0), Vec3::Z),
150        children![(
151            Mesh3d(meshes.add(Capsule3d::new(0.1, 0.125))),
152            MeshMaterial3d(materials.add(StandardMaterial {
153                base_color: LIME.into(),
154                emissive: LinearRgba::new(0.0, 4.0, 0.0, 0.0),
155                ..default()
156            })),
157            Transform::from_rotation(Quat::from_rotation_x(PI / 2.0)),
158        )],
159    ));
160
161    // blue point light
162    commands.spawn((
163        PointLight {
164            intensity: 100_000.0,
165            color: BLUE.into(),
166            shadows_enabled: true,
167            ..default()
168        },
169        Transform::from_xyz(0.0, 4.0, 0.0),
170        children![(
171            Mesh3d(meshes.add(Sphere::new(0.1).mesh().uv(32, 18))),
172            MeshMaterial3d(materials.add(StandardMaterial {
173                base_color: BLUE.into(),
174                emissive: LinearRgba::new(0.0, 0.0, 713.0, 0.0),
175                ..default()
176            })),
177        )],
178    ));
179
180    // directional 'sun' light
181    commands.spawn((
182        DirectionalLight {
183            illuminance: light_consts::lux::OVERCAST_DAY,
184            shadows_enabled: true,
185            ..default()
186        },
187        Transform {
188            translation: Vec3::new(0.0, 2.0, 0.0),
189            rotation: Quat::from_rotation_x(-PI / 4.),
190            ..default()
191        },
192        // The default cascade config is designed to handle large scenes.
193        // As this example has a much smaller world, we can tighten the shadow
194        // bounds for better visual quality.
195        CascadeShadowConfigBuilder {
196            first_cascade_far_bound: 4.0,
197            maximum_distance: 10.0,
198            ..default()
199        }
200        .build(),
201    ));
202
203    // example instructions
204
205    commands.spawn((
206        Text::default(),
207        Node {
208            position_type: PositionType::Absolute,
209            top: Val::Px(12.0),
210            left: Val::Px(12.0),
211            ..default()
212        },
213        children![
214            TextSpan(format!("Aperture: f/{:.0}\n", parameters.aperture_f_stops,)),
215            TextSpan(format!(
216                "Shutter speed: 1/{:.0}s\n",
217                1.0 / parameters.shutter_speed_s
218            )),
219            TextSpan(format!(
220                "Sensitivity: ISO {:.0}\n",
221                parameters.sensitivity_iso
222            )),
223            TextSpan::new("\n\n"),
224            TextSpan::new("Controls\n"),
225            TextSpan::new("---------------\n"),
226            TextSpan::new("Arrow keys - Move objects\n"),
227            TextSpan::new("1/2 - Decrease/Increase aperture\n"),
228            TextSpan::new("3/4 - Decrease/Increase shutter speed\n"),
229            TextSpan::new("5/6 - Decrease/Increase sensitivity\n"),
230            TextSpan::new("R - Reset exposure"),
231        ],
232    ));
233
234    // camera
235    commands.spawn((
236        Camera3d::default(),
237        Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
238        Exposure::from_physical_camera(**parameters),
239    ));
240}
Source

pub const fn rgb(red: f32, green: f32, blue: f32) -> LinearRgba

Construct a new LinearRgba color from (r, g, b) components, with the default alpha (1.0).

§Arguments
  • red - Red channel. [0.0, 1.0]
  • green - Green channel. [0.0, 1.0]
  • blue - Blue channel. [0.0, 1.0]
Examples found in repository?
examples/math/sampling_primitives.rs (line 56)
56const INSIDE_POINT_COLOR: LinearRgba = LinearRgba::rgb(0.855, 1.1, 0.01);
57/// Color used for the points on the boundary
58const BOUNDARY_POINT_COLOR: LinearRgba = LinearRgba::rgb(0.08, 0.2, 0.90);
More examples
Hide additional examples
examples/stress_tests/many_gizmos.rs (line 75)
65fn system(config: Res<Config>, time: Res<Time>, mut draw: Gizmos) {
66    if !config.fancy {
67        for _ in 0..(config.line_count / SYSTEM_COUNT) {
68            draw.line(Vec3::NEG_Y, Vec3::Y, Color::BLACK);
69        }
70    } else {
71        for i in 0..(config.line_count / SYSTEM_COUNT) {
72            let angle = i as f32 / (config.line_count / SYSTEM_COUNT) as f32 * TAU;
73
74            let vector = Vec2::from(ops::sin_cos(angle)).extend(ops::sin(time.elapsed_secs()));
75            let start_color = LinearRgba::rgb(vector.x, vector.z, 0.5);
76            let end_color = LinearRgba::rgb(-vector.z, -vector.y, 0.5);
77
78            draw.line_gradient(vector, -vector, start_color, end_color);
79        }
80    }
81}
examples/testbed/3d.rs (line 169)
151    pub fn setup(
152        mut commands: Commands,
153        mut meshes: ResMut<Assets<Mesh>>,
154        mut materials: ResMut<Assets<StandardMaterial>>,
155    ) {
156        commands.spawn((
157            Camera3d::default(),
158            Camera {
159                hdr: true,
160                ..default()
161            },
162            Tonemapping::TonyMcMapface,
163            Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
164            Bloom::NATURAL,
165            StateScoped(CURRENT_SCENE),
166        ));
167
168        let material_emissive1 = materials.add(StandardMaterial {
169            emissive: LinearRgba::rgb(13.99, 5.32, 2.0),
170            ..default()
171        });
172        let material_emissive2 = materials.add(StandardMaterial {
173            emissive: LinearRgba::rgb(2.0, 13.99, 5.32),
174            ..default()
175        });
176
177        let mesh = meshes.add(Sphere::new(0.5).mesh().ico(5).unwrap());
178
179        for z in -2..3_i32 {
180            let material = match (z % 2).abs() {
181                0 => material_emissive1.clone(),
182                1 => material_emissive2.clone(),
183                _ => unreachable!(),
184            };
185
186            commands.spawn((
187                Mesh3d(mesh.clone()),
188                MeshMaterial3d(material),
189                Transform::from_xyz(z as f32 * 2.0, 0.0, 0.0),
190                StateScoped(CURRENT_SCENE),
191            ));
192        }
193    }
examples/animation/color_animation.rs (line 47)
37fn setup(mut commands: Commands) {
38    commands.spawn(Camera2d);
39
40    // The color spaces `Oklaba`, `Laba`, `LinearRgba`, `Srgba` and `Xyza` all are either perceptually or physically linear.
41    // This property allows us to define curves, e.g. bezier curves through these spaces.
42
43    // Define the control points for the curve.
44    // For more information, please see the cubic curve example.
45    let colors = [
46        LinearRgba::WHITE,
47        LinearRgba::rgb(1., 1., 0.), // Yellow
48        LinearRgba::RED,
49        LinearRgba::BLACK,
50    ];
51    // Spawn a sprite using the provided colors as control points.
52    spawn_curve_sprite(&mut commands, 275., colors);
53
54    // Spawn another sprite using the provided colors as control points after converting them to the `Xyza` color space.
55    spawn_curve_sprite(&mut commands, 175., colors.map(Xyza::from));
56
57    spawn_curve_sprite(&mut commands, 75., colors.map(Oklaba::from));
58
59    // Other color spaces like `Srgba` or `Hsva` are neither perceptually nor physically linear.
60    // As such, we cannot use curves in these spaces.
61    // However, we can still mix these colors and animate that way. In fact, mixing colors works in any color space.
62
63    // Spawn a sprite using the provided colors for mixing.
64    spawn_mixed_sprite(&mut commands, -75., colors.map(Hsla::from));
65
66    spawn_mixed_sprite(&mut commands, -175., colors.map(Srgba::from));
67
68    spawn_mixed_sprite(&mut commands, -275., colors.map(Oklcha::from));
69}
examples/ecs/error_handling.rs (line 115)
67fn setup(
68    mut commands: Commands,
69    mut meshes: ResMut<Assets<Mesh>>,
70    mut materials: ResMut<Assets<StandardMaterial>>,
71) -> Result {
72    let mut seeded_rng = ChaCha8Rng::seed_from_u64(19878367467712);
73
74    // Make a plane for establishing space.
75    commands.spawn((
76        Mesh3d(meshes.add(Plane3d::default().mesh().size(12.0, 12.0))),
77        MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
78        Transform::from_xyz(0.0, -2.5, 0.0),
79    ));
80
81    // Spawn a light:
82    commands.spawn((
83        PointLight {
84            shadows_enabled: true,
85            ..default()
86        },
87        Transform::from_xyz(4.0, 8.0, 4.0),
88    ));
89
90    // Spawn a camera:
91    commands.spawn((
92        Camera3d::default(),
93        Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
94    ));
95
96    // Create a new sphere mesh:
97    let mut sphere_mesh = Sphere::new(1.0).mesh().ico(7)?;
98    sphere_mesh.generate_tangents()?;
99
100    // Spawn the mesh into the scene:
101    let mut sphere = commands.spawn((
102        Mesh3d(meshes.add(sphere_mesh.clone())),
103        MeshMaterial3d(materials.add(StandardMaterial::default())),
104        Transform::from_xyz(-1.0, 1.0, 0.0),
105    ));
106
107    // Generate random sample points:
108    let triangles = sphere_mesh.triangles()?;
109    let distribution = UniformMeshSampler::try_new(triangles)?;
110
111    // Setup sample points:
112    let point_mesh = meshes.add(Sphere::new(0.01).mesh().ico(3)?);
113    let point_material = materials.add(StandardMaterial {
114        base_color: Srgba::RED.into(),
115        emissive: LinearRgba::rgb(1.0, 0.0, 0.0),
116        ..default()
117    });
118
119    // Add sample points as children of the sphere:
120    for point in distribution.sample_iter(&mut seeded_rng).take(10000) {
121        sphere.with_child((
122            Mesh3d(point_mesh.clone()),
123            MeshMaterial3d(point_material.clone()),
124            Transform::from_translation(point),
125        ));
126    }
127
128    // Indicate the system completed successfully:
129    Ok(())
130}
examples/3d/bloom_3d.rs (line 42)
24fn setup_scene(
25    mut commands: Commands,
26    mut meshes: ResMut<Assets<Mesh>>,
27    mut materials: ResMut<Assets<StandardMaterial>>,
28) {
29    commands.spawn((
30        Camera3d::default(),
31        Camera {
32            hdr: true, // 1. HDR is required for bloom
33            clear_color: ClearColorConfig::Custom(Color::BLACK),
34            ..default()
35        },
36        Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended
37        Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
38        Bloom::NATURAL, // 3. Enable bloom for the camera
39    ));
40
41    let material_emissive1 = materials.add(StandardMaterial {
42        emissive: LinearRgba::rgb(0.0, 0.0, 150.0), // 4. Put something bright in a dark environment to see the effect
43        ..default()
44    });
45    let material_emissive2 = materials.add(StandardMaterial {
46        emissive: LinearRgba::rgb(1000.0, 1000.0, 1000.0),
47        ..default()
48    });
49    let material_emissive3 = materials.add(StandardMaterial {
50        emissive: LinearRgba::rgb(50.0, 0.0, 0.0),
51        ..default()
52    });
53    let material_non_emissive = materials.add(StandardMaterial {
54        base_color: Color::BLACK,
55        ..default()
56    });
57
58    let mesh = meshes.add(Sphere::new(0.4).mesh().ico(5).unwrap());
59
60    for x in -5..5 {
61        for z in -5..5 {
62            // This generates a pseudo-random integer between `[0, 6)`, but deterministically so
63            // the same spheres are always the same colors.
64            let mut hasher = DefaultHasher::new();
65            (x, z).hash(&mut hasher);
66            let rand = (hasher.finish() + 3) % 6;
67
68            let (material, scale) = match rand {
69                0 => (material_emissive1.clone(), 0.5),
70                1 => (material_emissive2.clone(), 0.1),
71                2 => (material_emissive3.clone(), 1.0),
72                3..=5 => (material_non_emissive.clone(), 1.5),
73                _ => unreachable!(),
74            };
75
76            commands.spawn((
77                Mesh3d(mesh.clone()),
78                MeshMaterial3d(material),
79                Transform::from_xyz(x as f32 * 2.0, 0.0, z as f32 * 2.0)
80                    .with_scale(Vec3::splat(scale)),
81                Bouncing,
82            ));
83        }
84    }
85
86    // example instructions
87    commands.spawn((
88        Text::default(),
89        Node {
90            position_type: PositionType::Absolute,
91            bottom: Val::Px(12.0),
92            left: Val::Px(12.0),
93            ..default()
94        },
95    ));
96}
Source

pub const fn with_red(self, red: f32) -> LinearRgba

Return a copy of this color with the red channel set to the given value.

Source

pub const fn with_green(self, green: f32) -> LinearRgba

Return a copy of this color with the green channel set to the given value.

Source

pub const fn with_blue(self, blue: f32) -> LinearRgba

Return a copy of this color with the blue channel set to the given value.

Source

pub fn as_u32(&self) -> u32

Converts this color to a u32.

Maps the RGBA channels in RGBA order to a little-endian byte array (GPUs are little-endian). A will be the most significant byte and R the least significant.

Examples found in repository?
examples/2d/mesh2d_manual.rs (line 90)
48fn star(
49    mut commands: Commands,
50    // We will add a new Mesh for the star being created
51    mut meshes: ResMut<Assets<Mesh>>,
52) {
53    // Let's define the mesh for the object we want to draw: a nice star.
54    // We will specify here what kind of topology is used to define the mesh,
55    // that is, how triangles are built from the vertices. We will use a
56    // triangle list, meaning that each vertex of the triangle has to be
57    // specified. We set `RenderAssetUsages::RENDER_WORLD`, meaning this mesh
58    // will not be accessible in future frames from the `meshes` resource, in
59    // order to save on memory once it has been uploaded to the GPU.
60    let mut star = Mesh::new(
61        PrimitiveTopology::TriangleList,
62        RenderAssetUsages::RENDER_WORLD,
63    );
64
65    // Vertices need to have a position attribute. We will use the following
66    // vertices (I hope you can spot the star in the schema).
67    //
68    //        1
69    //
70    //     10   2
71    // 9      0      3
72    //     8     4
73    //        6
74    //   7        5
75    //
76    // These vertices are specified in 3D space.
77    let mut v_pos = vec![[0.0, 0.0, 0.0]];
78    for i in 0..10 {
79        // The angle between each vertex is 1/10 of a full rotation.
80        let a = i as f32 * PI / 5.0;
81        // The radius of inner vertices (even indices) is 100. For outer vertices (odd indices) it's 200.
82        let r = (1 - i % 2) as f32 * 100.0 + 100.0;
83        // Add the vertex position.
84        v_pos.push([r * ops::sin(a), r * ops::cos(a), 0.0]);
85    }
86    // Set the position attribute
87    star.insert_attribute(Mesh::ATTRIBUTE_POSITION, v_pos);
88    // And a RGB color attribute as well. A built-in `Mesh::ATTRIBUTE_COLOR` exists, but we
89    // use a custom vertex attribute here for demonstration purposes.
90    let mut v_color: Vec<u32> = vec![LinearRgba::BLACK.as_u32()];
91    v_color.extend_from_slice(&[LinearRgba::from(YELLOW).as_u32(); 10]);
92    star.insert_attribute(
93        MeshVertexAttribute::new("Vertex_Color", 1, VertexFormat::Uint32),
94        v_color,
95    );
96
97    // Now, we specify the indices of the vertex that are going to compose the
98    // triangles in our star. Vertices in triangles have to be specified in CCW
99    // winding (that will be the front face, colored). Since we are using
100    // triangle list, we will specify each triangle as 3 vertices
101    //   First triangle: 0, 2, 1
102    //   Second triangle: 0, 3, 2
103    //   Third triangle: 0, 4, 3
104    //   etc
105    //   Last triangle: 0, 1, 10
106    let mut indices = vec![0, 1, 10];
107    for i in 2..=10 {
108        indices.extend_from_slice(&[0, i, i - 1]);
109    }
110    star.insert_indices(Indices::U32(indices));
111
112    // We can now spawn the entities for the star and the camera
113    commands.spawn((
114        // We use a marker component to identify the custom colored meshes
115        ColoredMesh2d,
116        // The `Handle<Mesh>` needs to be wrapped in a `Mesh2d` for 2D rendering
117        Mesh2d(meshes.add(star)),
118    ));
119
120    commands.spawn(Camera2d);
121}

Trait Implementations§

Source§

impl Add for LinearRgba

Source§

type Output = LinearRgba

The resulting type after applying the + operator.
Source§

fn add(self, rhs: LinearRgba) -> <LinearRgba as Add>::Output

Performs the + operation. Read more
Source§

impl AddAssign for LinearRgba

Source§

fn add_assign(&mut self, rhs: LinearRgba)

Performs the += operation. Read more
Source§

impl Alpha for LinearRgba

Source§

fn with_alpha(&self, alpha: f32) -> LinearRgba

Return a new version of this color with the given alpha value.
Source§

fn alpha(&self) -> f32

Return a the alpha component of this color.
Source§

fn set_alpha(&mut self, alpha: f32)

Sets the alpha component of this color.
Source§

fn is_fully_transparent(&self) -> bool

Is the alpha component of this color less than or equal to 0.0?
Source§

fn is_fully_opaque(&self) -> bool

Is the alpha component of this color greater than or equal to 1.0?
Source§

impl Animatable for LinearRgba

Source§

fn interpolate(a: &LinearRgba, b: &LinearRgba, t: f32) -> LinearRgba

Interpolates between a and b with an interpolation factor of time. Read more
Source§

fn blend(inputs: impl Iterator<Item = BlendInput<LinearRgba>>) -> LinearRgba

Blends one or more values together. Read more
Source§

impl Clone for LinearRgba

Source§

fn clone(&self) -> LinearRgba

Returns a copy 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 ColorToComponents for LinearRgba

Source§

fn to_f32_array(self) -> [f32; 4]

Convert to an f32 array
Source§

fn to_f32_array_no_alpha(self) -> [f32; 3]

Convert to an f32 array without the alpha value
Source§

fn to_vec4(self) -> Vec4

Convert to a Vec4
Source§

fn to_vec3(self) -> Vec3

Convert to a Vec3
Source§

fn from_f32_array(color: [f32; 4]) -> LinearRgba

Convert from an f32 array
Source§

fn from_f32_array_no_alpha(color: [f32; 3]) -> LinearRgba

Convert from an f32 array without the alpha value
Source§

fn from_vec4(color: Vec4) -> LinearRgba

Convert from a Vec4
Source§

fn from_vec3(color: Vec3) -> LinearRgba

Convert from a Vec3
Source§

impl ColorToPacked for LinearRgba

Source§

fn to_u8_array(self) -> [u8; 4]

Convert to [u8; 4] where that makes sense (Srgba is most relevant)
Source§

fn to_u8_array_no_alpha(self) -> [u8; 3]

Convert to [u8; 3] where that makes sense (Srgba is most relevant)
Source§

fn from_u8_array(color: [u8; 4]) -> LinearRgba

Convert from [u8; 4] where that makes sense (Srgba is most relevant)
Source§

fn from_u8_array_no_alpha(color: [u8; 3]) -> LinearRgba

Convert to [u8; 3] where that makes sense (Srgba is most relevant)
Source§

impl CreateFrom for LinearRgba

Source§

fn create_from<B>(reader: &mut Reader<B>) -> LinearRgba
where B: BufferRef,

Source§

impl Debug for LinearRgba

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for LinearRgba

Source§

fn default() -> LinearRgba

Construct a new LinearRgba color with the default values (white with full alpha).

Source§

impl<'de> Deserialize<'de> for LinearRgba

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<LinearRgba, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Div<f32> for LinearRgba

Source§

type Output = LinearRgba

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> <LinearRgba as Div<f32>>::Output

Performs the / operation. Read more
Source§

impl DivAssign<f32> for LinearRgba

Source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
Source§

impl EuclideanDistance for LinearRgba

Source§

fn distance_squared(&self, other: &LinearRgba) -> f32

Distance squared from self to other.
Source§

fn distance(&self, other: &Self) -> f32

Distance from self to other.
Source§

impl From<Color> for LinearRgba

Source§

fn from(value: Color) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<Hsla> for LinearRgba

Source§

fn from(value: Hsla) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<Hsva> for LinearRgba

Source§

fn from(value: Hsva) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<Hwba> for LinearRgba

Source§

fn from(value: Hwba) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<Laba> for LinearRgba

Source§

fn from(value: Laba) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<Lcha> for LinearRgba

Source§

fn from(value: Lcha) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Color

Source§

fn from(value: LinearRgba) -> Color

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Color

Source§

fn from(color: LinearRgba) -> Color

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Hsla

Source§

fn from(value: LinearRgba) -> Hsla

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Hsva

Source§

fn from(value: LinearRgba) -> Hsva

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Hwba

Source§

fn from(value: LinearRgba) -> Hwba

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Laba

Source§

fn from(value: LinearRgba) -> Laba

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Lcha

Source§

fn from(value: LinearRgba) -> Lcha

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Oklaba

Source§

fn from(value: LinearRgba) -> Oklaba

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Oklcha

Source§

fn from(value: LinearRgba) -> Oklcha

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Srgba

Source§

fn from(value: LinearRgba) -> Srgba

Converts to this type from the input type.
Source§

impl From<LinearRgba> for Xyza

Source§

fn from(_: LinearRgba) -> Xyza

Converts to this type from the input type.
Source§

impl From<Oklaba> for LinearRgba

Source§

fn from(value: Oklaba) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<Oklcha> for LinearRgba

Source§

fn from(value: Oklcha) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<Srgba> for LinearRgba

Source§

fn from(value: Srgba) -> LinearRgba

Converts to this type from the input type.
Source§

impl From<Xyza> for LinearRgba

Source§

fn from(_: Xyza) -> LinearRgba

Converts to this type from the input type.
Source§

impl FromArg for &'static LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = &'from_arg LinearRgba

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<&'static LinearRgba as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromArg for &'static mut LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = &'from_arg mut LinearRgba

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<&'static mut LinearRgba as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromArg for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = LinearRgba

The type to convert into. Read more
Source§

fn from_arg(arg: Arg<'_>) -> Result<<LinearRgba as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromReflect for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<LinearRgba>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl GetOwnership for &LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetOwnership for &mut LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetOwnership for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetTypeRegistration for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl Gray for LinearRgba

Source§

const BLACK: LinearRgba = Self::BLACK

A pure black color.
Source§

const WHITE: LinearRgba = Self::WHITE

A pure white color.
Source§

fn gray(lightness: f32) -> Self

Returns a grey color with the provided lightness from (0.0 - 1.0). 0 is black, 1 is white.
Source§

impl IntoReturn for &LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where &LinearRgba: 'into_return,

Converts Self into a Return value.
Source§

impl IntoReturn for &mut LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where &mut LinearRgba: 'into_return,

Converts Self into a Return value.
Source§

impl IntoReturn for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where LinearRgba: 'into_return,

Converts Self into a Return value.
Source§

impl Luminance for LinearRgba

Source§

fn luminance(&self) -> f32

Luminance calculated using the CIE XYZ formula.

Source§

fn with_luminance(&self, luminance: f32) -> LinearRgba

Return a new version of this color with the given luminance. The resulting color will be clamped to the valid range for the color space; for some color spaces, clamping may cause the hue or chroma to change.
Source§

fn darker(&self, amount: f32) -> LinearRgba

Return a darker version of this color. The amount should be between 0.0 and 1.0. The amount represents an absolute decrease in luminance, and is distributive: color.darker(a).darker(b) == color.darker(a + b). Colors are clamped to black if the amount would cause them to go below black. Read more
Source§

fn lighter(&self, amount: f32) -> LinearRgba

Return a lighter version of this color. The amount should be between 0.0 and 1.0. The amount represents an absolute increase in luminance, and is distributive: color.lighter(a).lighter(b) == color.lighter(a + b). Colors are clamped to white if the amount would cause them to go above white. Read more
Source§

impl Mix for LinearRgba

Source§

fn mix(&self, other: &LinearRgba, factor: f32) -> LinearRgba

Linearly interpolate between this and another color, by factor. Factor should be between 0.0 and 1.0.
Source§

fn mix_assign(&mut self, other: Self, factor: f32)

Linearly interpolate between this and another color, by factor, storing the result in this color. Factor should be between 0.0 and 1.0.
Source§

impl Mul<LinearRgba> for f32

Source§

type Output = LinearRgba

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: LinearRgba) -> <f32 as Mul<LinearRgba>>::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for LinearRgba

Source§

type Output = LinearRgba

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> <LinearRgba as Mul<f32>>::Output

Performs the * operation. Read more
Source§

impl MulAssign<f32> for LinearRgba

Source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
Source§

impl Neg for LinearRgba

Source§

type Output = LinearRgba

The resulting type after applying the - operator.
Source§

fn neg(self) -> <LinearRgba as Neg>::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for LinearRgba

Source§

fn eq(&self, other: &LinearRgba) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialReflect for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<LinearRgba>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<LinearRgba>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<LinearRgba>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn clone_value(&self) -> Box<dyn PartialReflect>

👎Deprecated since 0.16.0: to clone reflected values, prefer using reflect_clone. To convert reflected values to dynamic ones, use to_dynamic.
Clones Self into its dynamic representation. Read more
Source§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl ReadFrom for LinearRgba

Source§

fn read_from<B>(&mut self, reader: &mut Reader<B>)
where B: BufferRef,

Source§

impl Reflect for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_any(self: Box<LinearRgba>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<LinearRgba>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl Serialize for LinearRgba

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ShaderSize for LinearRgba

Source§

const SHADER_SIZE: NonZero<u64> = _

Represents WGSL Size (equivalent to ShaderType::min_size)
Source§

impl ShaderType for LinearRgba

Source§

fn min_size() -> NonZero<u64>

Represents the minimum size of Self (equivalent to GPUBufferBindingLayout.minBindingSize) Read more
Source§

fn size(&self) -> NonZero<u64>

Returns the size of Self at runtime Read more
Source§

fn assert_uniform_compat()

Source§

impl Struct for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field named name as a &dyn PartialReflect.
Source§

fn field_mut( &mut self, name: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field named name as a &mut dyn PartialReflect.
Source§

fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field with index index as a &dyn PartialReflect.
Source§

fn field_at_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field with index index as a &mut dyn PartialReflect.
Source§

fn name_at(&self, index: usize) -> Option<&str>

Returns the name of the field with index index.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the struct.
Source§

fn iter_fields(&self) -> FieldIter<'_>

Returns an iterator over the values of the reflectable fields for this struct.
Source§

fn to_dynamic_struct(&self) -> DynamicStruct

Source§

fn clone_dynamic(&self) -> DynamicStruct

👎Deprecated since 0.16.0: use to_dynamic_struct instead
Clones the struct into a DynamicStruct.
Source§

fn get_represented_struct_info(&self) -> Option<&'static StructInfo>

Will return None if TypeInfo is not available.
Source§

impl Sub for LinearRgba

Source§

type Output = LinearRgba

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: LinearRgba) -> <LinearRgba as Sub>::Output

Performs the - operation. Read more
Source§

impl SubAssign for LinearRgba

Source§

fn sub_assign(&mut self, rhs: LinearRgba)

Performs the -= operation. Read more
Source§

impl TypePath for LinearRgba
where LinearRgba: Any + Send + Sync,

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl Typed for LinearRgba
where LinearRgba: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
Source§

impl VectorSpace for LinearRgba

Source§

const ZERO: LinearRgba

The zero vector, which is the identity of addition for the vector space type.
Source§

fn lerp(self, rhs: Self, t: f32) -> Self

Perform vector space linear interpolation between this element and another, based on the parameter t. When t is 0, self is recovered. When t is 1, rhs is recovered. Read more
Source§

impl WriteInto for LinearRgba

Source§

fn write_into<B>(&self, writer: &mut Writer<B>)
where B: BufferMut,

Source§

impl Zeroable for LinearRgba

Source§

fn zeroed() -> Self

Source§

impl Copy for LinearRgba

Source§

impl Pod for LinearRgba

Source§

impl StructuralPartialEq for LinearRgba

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, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<V> Ease for V
where V: VectorSpace,

Source§

fn interpolating_curve_unbounded(start: V, end: V) -> impl Curve<V>

Given start and end values, produce a curve with unlimited domain that: Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<S> GetField for S
where S: Struct,

Source§

fn get_field<T>(&self, name: &str) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field named name, downcast to T.
Source§

fn get_field_mut<T>(&mut self, name: &str) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field named name, downcast to T.
Source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

Source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
Source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
Source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
Source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
Source§

impl<V> HasTangent for V
where V: VectorSpace,

Source§

type Tangent = V

The tangent type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> GpuArrayBufferable for T

Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> Reflectable for T

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,