pub struct OpacityComponent {
pub opacity: f32,
pub multiple_layers: bool,
}Expand description
Per-instance opacity multiplier for a renderable.
Intended to be attached as a descendant of a RenderableComponent.
Note: opacity is a multiplier (0..1). It combines with the instance color alpha and any sampled texture alpha in the shader.
Fields§
§opacity: f32§multiple_layers: boolIf true, this renderable should be treated as requiring correct multi-layer blending.
This routes the instance into the sorted (slow) transparent pass. When false, the instance can use the instanced (fast) transparent pass.
Implementations§
Source§impl OpacityComponent
impl OpacityComponent
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/opacity-example.rs (line 130)
91fn spawn_text_label_with_bg(
92 universe: &mut engine::Universe,
93 position: (f32, f32, f32),
94 text: &str,
95 bg_opacity: f32,
96) {
97 // T_root {
98 // T_bg { R_bg { Color black, Opacity } }
99 // T_scale { TXT { filtering } }
100 // }
101
102 let text_root = universe
103 .world
104 .add_component(TransformComponent::new().with_position(position.0, position.1, position.2));
105
106 // Background quad (slightly behind the glyph quads).
107 let (cols, rows) = text_block_dimensions(text);
108 let text_scale = 0.18_f32;
109 let pad_x = 0.55_f32;
110 let pad_y = 0.45_f32;
111 let bg_w = cols as f32 * text_scale + pad_x;
112 let bg_h = rows as f32 * text_scale + pad_y;
113
114 let bg_t = universe.world.add_component(
115 TransformComponent::new()
116 .with_position(1.5, 0.0, -0.02)
117 .with_scale(bg_w, bg_h, 1.0),
118 );
119 let bg_r = universe.world.add_component(RenderableComponent::square());
120 let _ = universe.attach(text_root, bg_t);
121 let _ = universe.attach(bg_t, bg_r);
122
123 let bg_c = universe
124 .world
125 .add_component(ColorComponent::rgba(0.0, 0.0, 0.0, 1.0));
126 let _ = universe.attach(bg_r, bg_c);
127
128 let bg_o = universe
129 .world
130 .add_component(OpacityComponent::new().with_opacity(bg_opacity));
131 let _ = universe.attach(bg_r, bg_o);
132
133 let text_scale_t = universe
134 .world
135 .add_component(TransformComponent::new().with_scale(text_scale, text_scale, 1.0));
136 let _ = universe.attach(text_root, text_scale_t);
137
138 let text_c = universe.world.add_component(TextComponent::new(text));
139 let _ = universe.attach(text_scale_t, text_c);
140
141 // Keep it crisp.
142 let filtering = universe
143 .world
144 .add_component(TextureFilteringComponent::nearest());
145 let _ = universe.attach(text_c, filtering);
146
147 // Force the label into the transparent pass so it layers correctly with the background.
148 // (Pass selection currently does not consider texture alpha.)
149 let color = universe
150 .world
151 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 0.998));
152 let _ = universe.attach(text_c, color);
153
154 universe.add(text_root);
155}
156
157fn spawn_demo_spot(
158 universe: &mut engine::Universe,
159 spot_pos: (f32, f32, f32),
160 opacity: f32,
161 multiple_layers: bool,
162 grid_n: i32,
163) {
164 let spot = universe
165 .world
166 .add_component(TransformComponent::new().with_position(spot_pos.0, spot_pos.1, spot_pos.2));
167
168 // All cubes inherit this color.
169 let white = universe
170 .world
171 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
172 let _ = universe.attach(spot, white);
173
174 // All cubes inherit this opacity (no per-cube OpacityComponent needed).
175 let mut oc = OpacityComponent::new().with_opacity(opacity);
176 if multiple_layers {
177 oc = oc.with_multiple_layers();
178 }
179 let oc = universe.world.add_component(oc);
180 let _ = universe.attach(spot, oc);
181
182 universe.add(spot);
183
184 // Cube grid.
185 let n = grid_n.max(1);
186 let spacing = if n <= 2 { 1.0 } else { 0.6 };
187 let cube_scale = if n <= 2 { 0.8 } else { 0.45 };
188 let half = (n as f32 - 1.0) * spacing * 0.5;
189
190 for z in 0..n {
191 for y in 0..n {
192 for x in 0..n {
193 let px = x as f32 * spacing - half;
194 let py = y as f32 * spacing;
195 let pz = z as f32 * spacing - half;
196
197 spawn_cube(
198 universe,
199 spot,
200 (px, py, pz),
201 (cube_scale, cube_scale, cube_scale),
202 None,
203 None,
204 );
205 }
206 }
207 }
208
209 // Label above.
210 let label = format!(
211 "opacity: {:.2}\nmulti-layer: {}",
212 opacity,
213 if multiple_layers { "true" } else { "false" }
214 );
215 // Keep labels away from the cube volume so they don't intersect.
216 let label_y = spot_pos.1 + (n as f32 * spacing) + 1.8;
217 let label_x = spot_pos.0 - (half + 0.6);
218 let label_z = spot_pos.2 - (half + 1.0);
219 spawn_text_label(universe, (label_x, label_y, label_z), &label);
220}
221
222fn spawn_demo_strip_pair(
223 universe: &mut engine::Universe,
224 spot_pos: (f32, f32, f32),
225 transparent_multiple_layers: bool,
226) {
227 let n_z: i32 = 4;
228 let spacing = 1.0;
229 let cube_scale = 0.8;
230 let half_z = (n_z as f32 - 1.0) * spacing * 0.5;
231
232 // Transparent strip (1x4 along Z).
233 let transparent_root = universe
234 .world
235 .add_component(TransformComponent::new().with_position(spot_pos.0, spot_pos.1, spot_pos.2));
236
237 let white = universe
238 .world
239 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
240 let _ = universe.attach(transparent_root, white);
241
242 let mut oc = OpacityComponent::new().with_opacity(0.50);
243 if transparent_multiple_layers {
244 oc = oc.with_multiple_layers();
245 }
246 let oc = universe.world.add_component(oc);
247 let _ = universe.attach(transparent_root, oc);
248
249 universe.add(transparent_root);
250
251 for z in 0..n_z {
252 let pz = z as f32 * spacing - half_z;
253 spawn_cube(
254 universe,
255 transparent_root,
256 (0.0, 0.0, pz),
257 (cube_scale, cube_scale, cube_scale),
258 None,
259 None,
260 );
261 }
262
263 // Opaque strip to the left, same spacing/scale.
264 let opaque_root = universe
265 .world
266 .add_component(TransformComponent::new().with_position(
267 spot_pos.0 - spacing,
268 spot_pos.1,
269 spot_pos.2,
270 ));
271 let white = universe
272 .world
273 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
274 let _ = universe.attach(opaque_root, white);
275 universe.add(opaque_root);
276
277 for z in 0..n_z {
278 let pz = z as f32 * spacing - half_z;
279 spawn_cube(
280 universe,
281 opaque_root,
282 (0.0, 0.0, pz),
283 (cube_scale, cube_scale, cube_scale),
284 None,
285 None,
286 );
287 }
288
289 let label = format!(
290 "mini: opaque + transparent strip\ntransparent opacity: 0.50\nmulti-layer: {}",
291 if transparent_multiple_layers {
292 "true"
293 } else {
294 "false"
295 }
296 );
297 let label_y = spot_pos.1 + spacing + 1.8;
298 let label_x = spot_pos.0 - (spacing * 2.6);
299 let label_z = spot_pos.2 - (half_z + 1.0);
300 spawn_text_label(universe, (label_x, label_y, label_z), &label);
301}
302
303fn spawn_demo_xy_plane(
304 universe: &mut engine::Universe,
305 spot_pos: (f32, f32, f32),
306 opacity: f32,
307 n_x: i32,
308 n_y: i32,
309 z: f32,
310) {
311 let spot = universe
312 .world
313 .add_component(TransformComponent::new().with_position(spot_pos.0, spot_pos.1, spot_pos.2));
314
315 let white = universe
316 .world
317 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
318 let _ = universe.attach(spot, white);
319
320 let oc = universe
321 .world
322 .add_component(OpacityComponent::new().with_opacity(opacity));
323 let _ = universe.attach(spot, oc);
324
325 universe.add(spot);
326
327 let nx = n_x.max(1);
328 let ny = n_y.max(1);
329 let spacing = 0.45;
330 let cube_scale = 0.35;
331 let half_x = (nx as f32 - 1.0) * spacing * 0.5;
332
333 for y in 0..ny {
334 for x in 0..nx {
335 let px = x as f32 * spacing - half_x;
336 let py = y as f32 * spacing;
337 spawn_cube(
338 universe,
339 spot,
340 (px, py, z),
341 (cube_scale, cube_scale, cube_scale),
342 None,
343 None,
344 );
345 }
346 }
347
348 // Label in front of the plane.
349 let label = format!(
350 "XY plane: {}x{}\nopacity: {:.2}\nmulti-layer: false",
351 nx, ny, opacity
352 );
353 let label_x = spot_pos.0 - (half_x + 0.6);
354 let label_y = spot_pos.1 + (ny as f32 * spacing) + 1.2;
355 let label_z = spot_pos.2 - 2.5;
356 spawn_text_label_with_bg(universe, (label_x, label_y, label_z), &label, 0.50);
357}Sourcepub fn with_value(self, value: u8) -> Self
pub fn with_value(self, value: u8) -> Self
Convenience: set opacity from an 8-bit value (0..255).
Sourcepub fn with_opacity(self, opacity: f32) -> Self
pub fn with_opacity(self, opacity: f32) -> Self
Examples found in repository?
examples/opacity-example.rs (line 130)
91fn spawn_text_label_with_bg(
92 universe: &mut engine::Universe,
93 position: (f32, f32, f32),
94 text: &str,
95 bg_opacity: f32,
96) {
97 // T_root {
98 // T_bg { R_bg { Color black, Opacity } }
99 // T_scale { TXT { filtering } }
100 // }
101
102 let text_root = universe
103 .world
104 .add_component(TransformComponent::new().with_position(position.0, position.1, position.2));
105
106 // Background quad (slightly behind the glyph quads).
107 let (cols, rows) = text_block_dimensions(text);
108 let text_scale = 0.18_f32;
109 let pad_x = 0.55_f32;
110 let pad_y = 0.45_f32;
111 let bg_w = cols as f32 * text_scale + pad_x;
112 let bg_h = rows as f32 * text_scale + pad_y;
113
114 let bg_t = universe.world.add_component(
115 TransformComponent::new()
116 .with_position(1.5, 0.0, -0.02)
117 .with_scale(bg_w, bg_h, 1.0),
118 );
119 let bg_r = universe.world.add_component(RenderableComponent::square());
120 let _ = universe.attach(text_root, bg_t);
121 let _ = universe.attach(bg_t, bg_r);
122
123 let bg_c = universe
124 .world
125 .add_component(ColorComponent::rgba(0.0, 0.0, 0.0, 1.0));
126 let _ = universe.attach(bg_r, bg_c);
127
128 let bg_o = universe
129 .world
130 .add_component(OpacityComponent::new().with_opacity(bg_opacity));
131 let _ = universe.attach(bg_r, bg_o);
132
133 let text_scale_t = universe
134 .world
135 .add_component(TransformComponent::new().with_scale(text_scale, text_scale, 1.0));
136 let _ = universe.attach(text_root, text_scale_t);
137
138 let text_c = universe.world.add_component(TextComponent::new(text));
139 let _ = universe.attach(text_scale_t, text_c);
140
141 // Keep it crisp.
142 let filtering = universe
143 .world
144 .add_component(TextureFilteringComponent::nearest());
145 let _ = universe.attach(text_c, filtering);
146
147 // Force the label into the transparent pass so it layers correctly with the background.
148 // (Pass selection currently does not consider texture alpha.)
149 let color = universe
150 .world
151 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 0.998));
152 let _ = universe.attach(text_c, color);
153
154 universe.add(text_root);
155}
156
157fn spawn_demo_spot(
158 universe: &mut engine::Universe,
159 spot_pos: (f32, f32, f32),
160 opacity: f32,
161 multiple_layers: bool,
162 grid_n: i32,
163) {
164 let spot = universe
165 .world
166 .add_component(TransformComponent::new().with_position(spot_pos.0, spot_pos.1, spot_pos.2));
167
168 // All cubes inherit this color.
169 let white = universe
170 .world
171 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
172 let _ = universe.attach(spot, white);
173
174 // All cubes inherit this opacity (no per-cube OpacityComponent needed).
175 let mut oc = OpacityComponent::new().with_opacity(opacity);
176 if multiple_layers {
177 oc = oc.with_multiple_layers();
178 }
179 let oc = universe.world.add_component(oc);
180 let _ = universe.attach(spot, oc);
181
182 universe.add(spot);
183
184 // Cube grid.
185 let n = grid_n.max(1);
186 let spacing = if n <= 2 { 1.0 } else { 0.6 };
187 let cube_scale = if n <= 2 { 0.8 } else { 0.45 };
188 let half = (n as f32 - 1.0) * spacing * 0.5;
189
190 for z in 0..n {
191 for y in 0..n {
192 for x in 0..n {
193 let px = x as f32 * spacing - half;
194 let py = y as f32 * spacing;
195 let pz = z as f32 * spacing - half;
196
197 spawn_cube(
198 universe,
199 spot,
200 (px, py, pz),
201 (cube_scale, cube_scale, cube_scale),
202 None,
203 None,
204 );
205 }
206 }
207 }
208
209 // Label above.
210 let label = format!(
211 "opacity: {:.2}\nmulti-layer: {}",
212 opacity,
213 if multiple_layers { "true" } else { "false" }
214 );
215 // Keep labels away from the cube volume so they don't intersect.
216 let label_y = spot_pos.1 + (n as f32 * spacing) + 1.8;
217 let label_x = spot_pos.0 - (half + 0.6);
218 let label_z = spot_pos.2 - (half + 1.0);
219 spawn_text_label(universe, (label_x, label_y, label_z), &label);
220}
221
222fn spawn_demo_strip_pair(
223 universe: &mut engine::Universe,
224 spot_pos: (f32, f32, f32),
225 transparent_multiple_layers: bool,
226) {
227 let n_z: i32 = 4;
228 let spacing = 1.0;
229 let cube_scale = 0.8;
230 let half_z = (n_z as f32 - 1.0) * spacing * 0.5;
231
232 // Transparent strip (1x4 along Z).
233 let transparent_root = universe
234 .world
235 .add_component(TransformComponent::new().with_position(spot_pos.0, spot_pos.1, spot_pos.2));
236
237 let white = universe
238 .world
239 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
240 let _ = universe.attach(transparent_root, white);
241
242 let mut oc = OpacityComponent::new().with_opacity(0.50);
243 if transparent_multiple_layers {
244 oc = oc.with_multiple_layers();
245 }
246 let oc = universe.world.add_component(oc);
247 let _ = universe.attach(transparent_root, oc);
248
249 universe.add(transparent_root);
250
251 for z in 0..n_z {
252 let pz = z as f32 * spacing - half_z;
253 spawn_cube(
254 universe,
255 transparent_root,
256 (0.0, 0.0, pz),
257 (cube_scale, cube_scale, cube_scale),
258 None,
259 None,
260 );
261 }
262
263 // Opaque strip to the left, same spacing/scale.
264 let opaque_root = universe
265 .world
266 .add_component(TransformComponent::new().with_position(
267 spot_pos.0 - spacing,
268 spot_pos.1,
269 spot_pos.2,
270 ));
271 let white = universe
272 .world
273 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
274 let _ = universe.attach(opaque_root, white);
275 universe.add(opaque_root);
276
277 for z in 0..n_z {
278 let pz = z as f32 * spacing - half_z;
279 spawn_cube(
280 universe,
281 opaque_root,
282 (0.0, 0.0, pz),
283 (cube_scale, cube_scale, cube_scale),
284 None,
285 None,
286 );
287 }
288
289 let label = format!(
290 "mini: opaque + transparent strip\ntransparent opacity: 0.50\nmulti-layer: {}",
291 if transparent_multiple_layers {
292 "true"
293 } else {
294 "false"
295 }
296 );
297 let label_y = spot_pos.1 + spacing + 1.8;
298 let label_x = spot_pos.0 - (spacing * 2.6);
299 let label_z = spot_pos.2 - (half_z + 1.0);
300 spawn_text_label(universe, (label_x, label_y, label_z), &label);
301}
302
303fn spawn_demo_xy_plane(
304 universe: &mut engine::Universe,
305 spot_pos: (f32, f32, f32),
306 opacity: f32,
307 n_x: i32,
308 n_y: i32,
309 z: f32,
310) {
311 let spot = universe
312 .world
313 .add_component(TransformComponent::new().with_position(spot_pos.0, spot_pos.1, spot_pos.2));
314
315 let white = universe
316 .world
317 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
318 let _ = universe.attach(spot, white);
319
320 let oc = universe
321 .world
322 .add_component(OpacityComponent::new().with_opacity(opacity));
323 let _ = universe.attach(spot, oc);
324
325 universe.add(spot);
326
327 let nx = n_x.max(1);
328 let ny = n_y.max(1);
329 let spacing = 0.45;
330 let cube_scale = 0.35;
331 let half_x = (nx as f32 - 1.0) * spacing * 0.5;
332
333 for y in 0..ny {
334 for x in 0..nx {
335 let px = x as f32 * spacing - half_x;
336 let py = y as f32 * spacing;
337 spawn_cube(
338 universe,
339 spot,
340 (px, py, z),
341 (cube_scale, cube_scale, cube_scale),
342 None,
343 None,
344 );
345 }
346 }
347
348 // Label in front of the plane.
349 let label = format!(
350 "XY plane: {}x{}\nopacity: {:.2}\nmulti-layer: false",
351 nx, ny, opacity
352 );
353 let label_x = spot_pos.0 - (half_x + 0.6);
354 let label_y = spot_pos.1 + (ny as f32 * spacing) + 1.2;
355 let label_z = spot_pos.2 - 2.5;
356 spawn_text_label_with_bg(universe, (label_x, label_y, label_z), &label, 0.50);
357}Sourcepub fn with_multiple_layers(self) -> Self
pub fn with_multiple_layers(self) -> Self
Mark this opacity as requiring correct multi-layer blending.
This opts the renderable into the sorted transparent pass (no instancing).
Examples found in repository?
examples/opacity-example.rs (line 177)
157fn spawn_demo_spot(
158 universe: &mut engine::Universe,
159 spot_pos: (f32, f32, f32),
160 opacity: f32,
161 multiple_layers: bool,
162 grid_n: i32,
163) {
164 let spot = universe
165 .world
166 .add_component(TransformComponent::new().with_position(spot_pos.0, spot_pos.1, spot_pos.2));
167
168 // All cubes inherit this color.
169 let white = universe
170 .world
171 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
172 let _ = universe.attach(spot, white);
173
174 // All cubes inherit this opacity (no per-cube OpacityComponent needed).
175 let mut oc = OpacityComponent::new().with_opacity(opacity);
176 if multiple_layers {
177 oc = oc.with_multiple_layers();
178 }
179 let oc = universe.world.add_component(oc);
180 let _ = universe.attach(spot, oc);
181
182 universe.add(spot);
183
184 // Cube grid.
185 let n = grid_n.max(1);
186 let spacing = if n <= 2 { 1.0 } else { 0.6 };
187 let cube_scale = if n <= 2 { 0.8 } else { 0.45 };
188 let half = (n as f32 - 1.0) * spacing * 0.5;
189
190 for z in 0..n {
191 for y in 0..n {
192 for x in 0..n {
193 let px = x as f32 * spacing - half;
194 let py = y as f32 * spacing;
195 let pz = z as f32 * spacing - half;
196
197 spawn_cube(
198 universe,
199 spot,
200 (px, py, pz),
201 (cube_scale, cube_scale, cube_scale),
202 None,
203 None,
204 );
205 }
206 }
207 }
208
209 // Label above.
210 let label = format!(
211 "opacity: {:.2}\nmulti-layer: {}",
212 opacity,
213 if multiple_layers { "true" } else { "false" }
214 );
215 // Keep labels away from the cube volume so they don't intersect.
216 let label_y = spot_pos.1 + (n as f32 * spacing) + 1.8;
217 let label_x = spot_pos.0 - (half + 0.6);
218 let label_z = spot_pos.2 - (half + 1.0);
219 spawn_text_label(universe, (label_x, label_y, label_z), &label);
220}
221
222fn spawn_demo_strip_pair(
223 universe: &mut engine::Universe,
224 spot_pos: (f32, f32, f32),
225 transparent_multiple_layers: bool,
226) {
227 let n_z: i32 = 4;
228 let spacing = 1.0;
229 let cube_scale = 0.8;
230 let half_z = (n_z as f32 - 1.0) * spacing * 0.5;
231
232 // Transparent strip (1x4 along Z).
233 let transparent_root = universe
234 .world
235 .add_component(TransformComponent::new().with_position(spot_pos.0, spot_pos.1, spot_pos.2));
236
237 let white = universe
238 .world
239 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
240 let _ = universe.attach(transparent_root, white);
241
242 let mut oc = OpacityComponent::new().with_opacity(0.50);
243 if transparent_multiple_layers {
244 oc = oc.with_multiple_layers();
245 }
246 let oc = universe.world.add_component(oc);
247 let _ = universe.attach(transparent_root, oc);
248
249 universe.add(transparent_root);
250
251 for z in 0..n_z {
252 let pz = z as f32 * spacing - half_z;
253 spawn_cube(
254 universe,
255 transparent_root,
256 (0.0, 0.0, pz),
257 (cube_scale, cube_scale, cube_scale),
258 None,
259 None,
260 );
261 }
262
263 // Opaque strip to the left, same spacing/scale.
264 let opaque_root = universe
265 .world
266 .add_component(TransformComponent::new().with_position(
267 spot_pos.0 - spacing,
268 spot_pos.1,
269 spot_pos.2,
270 ));
271 let white = universe
272 .world
273 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
274 let _ = universe.attach(opaque_root, white);
275 universe.add(opaque_root);
276
277 for z in 0..n_z {
278 let pz = z as f32 * spacing - half_z;
279 spawn_cube(
280 universe,
281 opaque_root,
282 (0.0, 0.0, pz),
283 (cube_scale, cube_scale, cube_scale),
284 None,
285 None,
286 );
287 }
288
289 let label = format!(
290 "mini: opaque + transparent strip\ntransparent opacity: 0.50\nmulti-layer: {}",
291 if transparent_multiple_layers {
292 "true"
293 } else {
294 "false"
295 }
296 );
297 let label_y = spot_pos.1 + spacing + 1.8;
298 let label_x = spot_pos.0 - (spacing * 2.6);
299 let label_z = spot_pos.2 - (half_z + 1.0);
300 spawn_text_label(universe, (label_x, label_y, label_z), &label);
301}Trait Implementations§
Source§impl Clone for OpacityComponent
impl Clone for OpacityComponent
Source§fn clone(&self) -> OpacityComponent
fn clone(&self) -> OpacityComponent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Component for OpacityComponent
impl Component for OpacityComponent
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Short debug/type name for this component kind (e.g. “transform”, “camera”).
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn init(&mut self, emit: &mut dyn SignalEmitter, component: ComponentId)
fn init(&mut self, emit: &mut dyn SignalEmitter, component: ComponentId)
Called when component is added to the World
Source§fn to_mms_ast(&self, _world: &World) -> ComponentExpression
fn to_mms_ast(&self, _world: &World) -> ComponentExpression
Encode this component as an MMS Component Expression AST node. Read more
fn set_id(&mut self, _component: ComponentId)
Source§fn cleanup(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
fn cleanup(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
Called when component is removed from the World.
impl Copy for OpacityComponent
Source§impl Debug for OpacityComponent
impl Debug for OpacityComponent
Auto Trait Implementations§
impl Freeze for OpacityComponent
impl RefUnwindSafe for OpacityComponent
impl Send for OpacityComponent
impl Sync for OpacityComponent
impl Unpin for OpacityComponent
impl UnsafeUnpin for OpacityComponent
impl UnwindSafe for OpacityComponent
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
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>
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)
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)
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.