#[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.
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
impl LinearRgba
Sourcepub const BLACK: LinearRgba
pub const BLACK: LinearRgba
A fully black color with full alpha.
Sourcepub const WHITE: LinearRgba
pub const WHITE: LinearRgba
A fully white color with full alpha.
Sourcepub const NONE: LinearRgba
pub const NONE: LinearRgba
A fully transparent color.
Sourcepub const RED: LinearRgba
pub const RED: LinearRgba
A fully red color with full alpha.
Sourcepub const GREEN: LinearRgba
pub const GREEN: LinearRgba
A fully green color with full alpha.
Sourcepub const BLUE: LinearRgba
pub const BLUE: LinearRgba
A fully blue color with full alpha.
Sourcepub const NAN: LinearRgba
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
.
Sourcepub const fn new(red: f32, green: f32, blue: f32, alpha: f32) -> LinearRgba
pub const fn new(red: f32, green: f32, blue: f32, alpha: f32) -> LinearRgba
Construct a new LinearRgba
color from components.
Examples found in repository?
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
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}
Sourcepub const fn rgb(red: f32, green: f32, blue: f32) -> LinearRgba
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?
More examples
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}
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 }
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}
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}
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}
Sourcepub const fn with_red(self, red: f32) -> LinearRgba
pub const fn with_red(self, red: f32) -> LinearRgba
Return a copy of this color with the red channel set to the given value.
Sourcepub const fn with_green(self, green: f32) -> LinearRgba
pub const fn with_green(self, green: f32) -> LinearRgba
Return a copy of this color with the green channel set to the given value.
Sourcepub const fn with_blue(self, blue: f32) -> LinearRgba
pub const fn with_blue(self, blue: f32) -> LinearRgba
Return a copy of this color with the blue channel set to the given value.
Sourcepub fn as_u32(&self) -> u32
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?
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
impl Add for LinearRgba
Source§type Output = LinearRgba
type Output = LinearRgba
+
operator.Source§fn add(self, rhs: LinearRgba) -> <LinearRgba as Add>::Output
fn add(self, rhs: LinearRgba) -> <LinearRgba as Add>::Output
+
operation. Read moreSource§impl AddAssign for LinearRgba
impl AddAssign for LinearRgba
Source§fn add_assign(&mut self, rhs: LinearRgba)
fn add_assign(&mut self, rhs: LinearRgba)
+=
operation. Read moreSource§impl Alpha for LinearRgba
impl Alpha for LinearRgba
Source§fn with_alpha(&self, alpha: f32) -> LinearRgba
fn with_alpha(&self, alpha: f32) -> LinearRgba
Source§fn is_fully_transparent(&self) -> bool
fn is_fully_transparent(&self) -> bool
Source§fn is_fully_opaque(&self) -> bool
fn is_fully_opaque(&self) -> bool
Source§impl Animatable for LinearRgba
impl Animatable for LinearRgba
Source§fn interpolate(a: &LinearRgba, b: &LinearRgba, t: f32) -> LinearRgba
fn interpolate(a: &LinearRgba, b: &LinearRgba, t: f32) -> LinearRgba
Source§fn blend(inputs: impl Iterator<Item = BlendInput<LinearRgba>>) -> LinearRgba
fn blend(inputs: impl Iterator<Item = BlendInput<LinearRgba>>) -> LinearRgba
Source§impl Clone for LinearRgba
impl Clone for LinearRgba
Source§fn clone(&self) -> LinearRgba
fn clone(&self) -> LinearRgba
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl ColorToComponents for LinearRgba
impl ColorToComponents for LinearRgba
Source§fn to_f32_array(self) -> [f32; 4]
fn to_f32_array(self) -> [f32; 4]
Source§fn to_f32_array_no_alpha(self) -> [f32; 3]
fn to_f32_array_no_alpha(self) -> [f32; 3]
Source§fn from_f32_array(color: [f32; 4]) -> LinearRgba
fn from_f32_array(color: [f32; 4]) -> LinearRgba
Source§fn from_f32_array_no_alpha(color: [f32; 3]) -> LinearRgba
fn from_f32_array_no_alpha(color: [f32; 3]) -> LinearRgba
Source§fn from_vec4(color: Vec4) -> LinearRgba
fn from_vec4(color: Vec4) -> LinearRgba
Source§fn from_vec3(color: Vec3) -> LinearRgba
fn from_vec3(color: Vec3) -> LinearRgba
Source§impl ColorToPacked for LinearRgba
impl ColorToPacked for LinearRgba
Source§fn to_u8_array(self) -> [u8; 4]
fn to_u8_array(self) -> [u8; 4]
Source§fn to_u8_array_no_alpha(self) -> [u8; 3]
fn to_u8_array_no_alpha(self) -> [u8; 3]
Source§fn from_u8_array(color: [u8; 4]) -> LinearRgba
fn from_u8_array(color: [u8; 4]) -> LinearRgba
Source§fn from_u8_array_no_alpha(color: [u8; 3]) -> LinearRgba
fn from_u8_array_no_alpha(color: [u8; 3]) -> LinearRgba
Source§impl CreateFrom for LinearRgba
impl CreateFrom for LinearRgba
fn create_from<B>(reader: &mut Reader<B>) -> LinearRgbawhere
B: BufferRef,
Source§impl Debug for LinearRgba
impl Debug for LinearRgba
Source§impl Default for LinearRgba
impl Default for LinearRgba
Source§fn default() -> LinearRgba
fn default() -> LinearRgba
Construct a new LinearRgba
color with the default values (white with full alpha).
Source§impl<'de> Deserialize<'de> for LinearRgba
impl<'de> Deserialize<'de> for LinearRgba
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LinearRgba, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LinearRgba, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Div<f32> for LinearRgba
impl Div<f32> for LinearRgba
Source§impl DivAssign<f32> for LinearRgba
impl DivAssign<f32> for LinearRgba
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
/=
operation. Read moreSource§impl EuclideanDistance for LinearRgba
impl EuclideanDistance for LinearRgba
Source§fn distance_squared(&self, other: &LinearRgba) -> f32
fn distance_squared(&self, other: &LinearRgba) -> f32
self
to other
.Source§impl From<Color> for LinearRgba
impl From<Color> for LinearRgba
Source§fn from(value: Color) -> LinearRgba
fn from(value: Color) -> LinearRgba
Source§impl From<Hsla> for LinearRgba
impl From<Hsla> for LinearRgba
Source§fn from(value: Hsla) -> LinearRgba
fn from(value: Hsla) -> LinearRgba
Source§impl From<Hsva> for LinearRgba
impl From<Hsva> for LinearRgba
Source§fn from(value: Hsva) -> LinearRgba
fn from(value: Hsva) -> LinearRgba
Source§impl From<Hwba> for LinearRgba
impl From<Hwba> for LinearRgba
Source§fn from(value: Hwba) -> LinearRgba
fn from(value: Hwba) -> LinearRgba
Source§impl From<Laba> for LinearRgba
impl From<Laba> for LinearRgba
Source§fn from(value: Laba) -> LinearRgba
fn from(value: Laba) -> LinearRgba
Source§impl From<Lcha> for LinearRgba
impl From<Lcha> for LinearRgba
Source§fn from(value: Lcha) -> LinearRgba
fn from(value: Lcha) -> LinearRgba
Source§impl From<LinearRgba> for Color
impl From<LinearRgba> for Color
Source§fn from(value: LinearRgba) -> Color
fn from(value: LinearRgba) -> Color
Source§impl From<LinearRgba> for Color
impl From<LinearRgba> for Color
Source§fn from(color: LinearRgba) -> Color
fn from(color: LinearRgba) -> Color
Source§impl From<LinearRgba> for Hsla
impl From<LinearRgba> for Hsla
Source§fn from(value: LinearRgba) -> Hsla
fn from(value: LinearRgba) -> Hsla
Source§impl From<LinearRgba> for Hsva
impl From<LinearRgba> for Hsva
Source§fn from(value: LinearRgba) -> Hsva
fn from(value: LinearRgba) -> Hsva
Source§impl From<LinearRgba> for Hwba
impl From<LinearRgba> for Hwba
Source§fn from(value: LinearRgba) -> Hwba
fn from(value: LinearRgba) -> Hwba
Source§impl From<LinearRgba> for Laba
impl From<LinearRgba> for Laba
Source§fn from(value: LinearRgba) -> Laba
fn from(value: LinearRgba) -> Laba
Source§impl From<LinearRgba> for Lcha
impl From<LinearRgba> for Lcha
Source§fn from(value: LinearRgba) -> Lcha
fn from(value: LinearRgba) -> Lcha
Source§impl From<LinearRgba> for Oklaba
impl From<LinearRgba> for Oklaba
Source§fn from(value: LinearRgba) -> Oklaba
fn from(value: LinearRgba) -> Oklaba
Source§impl From<LinearRgba> for Oklcha
impl From<LinearRgba> for Oklcha
Source§fn from(value: LinearRgba) -> Oklcha
fn from(value: LinearRgba) -> Oklcha
Source§impl From<LinearRgba> for Srgba
impl From<LinearRgba> for Srgba
Source§fn from(value: LinearRgba) -> Srgba
fn from(value: LinearRgba) -> Srgba
Source§impl From<LinearRgba> for Xyza
impl From<LinearRgba> for Xyza
Source§fn from(_: LinearRgba) -> Xyza
fn from(_: LinearRgba) -> Xyza
Source§impl From<Oklaba> for LinearRgba
impl From<Oklaba> for LinearRgba
Source§fn from(value: Oklaba) -> LinearRgba
fn from(value: Oklaba) -> LinearRgba
Source§impl From<Oklcha> for LinearRgba
impl From<Oklcha> for LinearRgba
Source§fn from(value: Oklcha) -> LinearRgba
fn from(value: Oklcha) -> LinearRgba
Source§impl From<Srgba> for LinearRgba
impl From<Srgba> for LinearRgba
Source§fn from(value: Srgba) -> LinearRgba
fn from(value: Srgba) -> LinearRgba
Source§impl From<Xyza> for LinearRgba
impl From<Xyza> for LinearRgba
Source§fn from(_: Xyza) -> LinearRgba
fn from(_: Xyza) -> LinearRgba
Source§impl FromArg for &'static LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for &'static LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromArg for &'static mut LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for &'static mut LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromArg for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromReflect for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromReflect for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<LinearRgba>
fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<LinearRgba>
Self
from a reflected value.Source§fn take_from_reflect(
reflect: Box<dyn PartialReflect>,
) -> Result<Self, Box<dyn PartialReflect>>
fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>
Self
using,
constructing the value using from_reflect
if that fails. Read moreSource§impl GetOwnership for &LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for &LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetOwnership for &mut LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for &mut LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetOwnership for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetTypeRegistration for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetTypeRegistration for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn get_type_registration() -> TypeRegistration
fn get_type_registration() -> TypeRegistration
TypeRegistration
for this type.Source§fn register_type_dependencies(registry: &mut TypeRegistry)
fn register_type_dependencies(registry: &mut TypeRegistry)
Source§impl Gray for LinearRgba
impl Gray for LinearRgba
Source§impl IntoReturn for &LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for &LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_return<'into_return>(self) -> Return<'into_return>where
&LinearRgba: 'into_return,
fn into_return<'into_return>(self) -> Return<'into_return>where
&LinearRgba: 'into_return,
Source§impl IntoReturn for &mut LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for &mut LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_return<'into_return>(self) -> Return<'into_return>where
&mut LinearRgba: 'into_return,
fn into_return<'into_return>(self) -> Return<'into_return>where
&mut LinearRgba: 'into_return,
Source§impl IntoReturn for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_return<'into_return>(self) -> Return<'into_return>where
LinearRgba: 'into_return,
fn into_return<'into_return>(self) -> Return<'into_return>where
LinearRgba: 'into_return,
Source§impl Luminance for LinearRgba
impl Luminance for LinearRgba
Source§fn luminance(&self) -> f32
fn luminance(&self) -> f32
Luminance calculated using the CIE XYZ formula.
Source§fn with_luminance(&self, luminance: f32) -> LinearRgba
fn with_luminance(&self, luminance: f32) -> LinearRgba
Source§fn darker(&self, amount: f32) -> LinearRgba
fn darker(&self, amount: f32) -> LinearRgba
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 moreSource§fn lighter(&self, amount: f32) -> LinearRgba
fn lighter(&self, amount: f32) -> LinearRgba
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 moreSource§impl Mix for LinearRgba
impl Mix for LinearRgba
Source§fn mix(&self, other: &LinearRgba, factor: f32) -> LinearRgba
fn mix(&self, other: &LinearRgba, factor: f32) -> LinearRgba
Source§fn mix_assign(&mut self, other: Self, factor: f32)
fn mix_assign(&mut self, other: Self, factor: f32)
Source§impl Mul<LinearRgba> for f32
impl Mul<LinearRgba> for f32
Source§type Output = LinearRgba
type Output = LinearRgba
*
operator.Source§fn mul(self, rhs: LinearRgba) -> <f32 as Mul<LinearRgba>>::Output
fn mul(self, rhs: LinearRgba) -> <f32 as Mul<LinearRgba>>::Output
*
operation. Read moreSource§impl Mul<f32> for LinearRgba
impl Mul<f32> for LinearRgba
Source§impl MulAssign<f32> for LinearRgba
impl MulAssign<f32> for LinearRgba
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
*=
operation. Read moreSource§impl Neg for LinearRgba
impl Neg for LinearRgba
Source§impl PartialEq for LinearRgba
impl PartialEq for LinearRgba
Source§impl PartialReflect for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl PartialReflect for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
Source§fn try_apply(
&mut self,
value: &(dyn PartialReflect + 'static),
) -> Result<(), ApplyError>
fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>
Source§fn reflect_kind(&self) -> ReflectKind
fn reflect_kind(&self) -> ReflectKind
Source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
Source§fn reflect_owned(self: Box<LinearRgba>) -> ReflectOwned
fn reflect_owned(self: Box<LinearRgba>) -> ReflectOwned
Source§fn try_into_reflect(
self: Box<LinearRgba>,
) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
fn try_into_reflect( self: Box<LinearRgba>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
Source§fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
Source§fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>
fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>
Source§fn into_partial_reflect(self: Box<LinearRgba>) -> Box<dyn PartialReflect>
fn into_partial_reflect(self: Box<LinearRgba>) -> Box<dyn PartialReflect>
Source§fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
Source§fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
Source§fn reflect_partial_eq(
&self,
value: &(dyn PartialReflect + 'static),
) -> Option<bool>
fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>
Source§fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
Self
using reflection. Read moreSource§fn apply(&mut self, value: &(dyn PartialReflect + 'static))
fn apply(&mut self, value: &(dyn PartialReflect + 'static))
Source§fn clone_value(&self) -> Box<dyn PartialReflect>
fn clone_value(&self) -> Box<dyn PartialReflect>
reflect_clone
. To convert reflected values to dynamic ones, use to_dynamic
.Self
into its dynamic representation. Read moreSource§fn to_dynamic(&self) -> Box<dyn PartialReflect>
fn to_dynamic(&self) -> Box<dyn PartialReflect>
Source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
Source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
Source§impl ReadFrom for LinearRgba
impl ReadFrom for LinearRgba
Source§impl Reflect for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Reflect for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_any(self: Box<LinearRgba>) -> Box<dyn Any>
fn into_any(self: Box<LinearRgba>) -> Box<dyn Any>
Box<dyn Any>
. Read moreSource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut dyn Any
. Read moreSource§fn into_reflect(self: Box<LinearRgba>) -> Box<dyn Reflect>
fn into_reflect(self: Box<LinearRgba>) -> Box<dyn Reflect>
Source§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
Source§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
Source§impl Serialize for LinearRgba
impl Serialize for LinearRgba
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl ShaderSize for LinearRgba
impl ShaderSize for LinearRgba
Source§const SHADER_SIZE: NonZero<u64> = _
const SHADER_SIZE: NonZero<u64> = _
ShaderType::min_size
)Source§impl ShaderType for LinearRgba
impl ShaderType for LinearRgba
Source§fn assert_uniform_compat()
fn assert_uniform_compat()
Self
meets the requirements of the
uniform address space restrictions on stored values and the
uniform address space layout constraints Read moreSource§impl Struct for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Struct for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
name
as a &dyn PartialReflect
.Source§fn field_mut(
&mut self,
name: &str,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_mut( &mut self, name: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>
name
as a
&mut dyn PartialReflect
.Source§fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
index
as a
&dyn PartialReflect
.Source§fn field_at_mut(
&mut self,
index: usize,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_at_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>
index
as a &mut dyn PartialReflect
.Source§fn name_at(&self, index: usize) -> Option<&str>
fn name_at(&self, index: usize) -> Option<&str>
index
.Source§fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn to_dynamic_struct(&self) -> DynamicStruct
Source§fn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
to_dynamic_struct
insteadDynamicStruct
.Source§fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
None
if TypeInfo
is not available.Source§impl Sub for LinearRgba
impl Sub for LinearRgba
Source§type Output = LinearRgba
type Output = LinearRgba
-
operator.Source§fn sub(self, rhs: LinearRgba) -> <LinearRgba as Sub>::Output
fn sub(self, rhs: LinearRgba) -> <LinearRgba as Sub>::Output
-
operation. Read moreSource§impl SubAssign for LinearRgba
impl SubAssign for LinearRgba
Source§fn sub_assign(&mut self, rhs: LinearRgba)
fn sub_assign(&mut self, rhs: LinearRgba)
-=
operation. Read moreSource§impl TypePath for LinearRgba
impl TypePath for LinearRgba
Source§fn type_path() -> &'static str
fn type_path() -> &'static str
Source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
Source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
Source§impl Typed for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Typed for LinearRgbawhere
LinearRgba: Any + Send + Sync,
f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl VectorSpace for LinearRgba
impl VectorSpace for LinearRgba
Source§const ZERO: LinearRgba
const ZERO: LinearRgba
Source§impl WriteInto for LinearRgba
impl WriteInto for LinearRgba
fn write_into<B>(&self, writer: &mut Writer<B>)where
B: BufferMut,
impl Copy for LinearRgba
impl Pod for LinearRgba
impl StructuralPartialEq for LinearRgba
Auto Trait Implementations§
impl Freeze for LinearRgba
impl RefUnwindSafe for LinearRgba
impl Send for LinearRgba
impl Sync for LinearRgba
impl Unpin for LinearRgba
impl UnwindSafe for LinearRgba
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
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
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
Source§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
TypePath::type_path
.Source§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
Source§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
TypePath::type_ident
.Source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
TypePath::crate_name
.Source§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
Source§impl<T> DynamicTyped for Twhere
T: Typed,
impl<T> DynamicTyped for Twhere
T: Typed,
Source§fn reflect_type_info(&self) -> &'static TypeInfo
fn reflect_type_info(&self) -> &'static TypeInfo
Typed::type_info
.Source§impl<V> Ease for Vwhere
V: VectorSpace,
impl<V> Ease for Vwhere
V: VectorSpace,
Source§fn interpolating_curve_unbounded(start: V, end: V) -> impl Curve<V>
fn interpolating_curve_unbounded(start: V, end: V) -> impl Curve<V>
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.
Source§impl<S> GetField for Swhere
S: Struct,
impl<S> GetField for Swhere
S: Struct,
Source§impl<T> GetPath for T
impl<T> GetPath for T
Source§fn reflect_path<'p>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
path
. Read moreSource§fn reflect_path_mut<'p>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
path
. Read moreSource§fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
path
. Read moreSource§fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
path
. Read moreSource§impl<V> HasTangent for Vwhere
V: VectorSpace,
impl<V> HasTangent for Vwhere
V: VectorSpace,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.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
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.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
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.