Struct shanimation_rs::renderable::RenderableBuilder
source · pub struct RenderableBuilder { /* private fields */ }Implementations§
source§impl RenderableBuilder
impl RenderableBuilder
pub fn add_child(&mut self, child: Renderable) -> &mut Self
sourcepub fn with_position(&mut self, x: f64, y: f64) -> &mut Self
pub fn with_position(&mut self, x: f64, y: f64) -> &mut Self
Examples found in repository?
examples/keyframed_gradient.rs (line 13)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() -> Result<(), MainError> {
let main_renderable = Renderable::builder()
.with_position(0.2, 0.1)
.with_size(0.3, 0.3)
.with_rotation(2.0)
.with_behaviour(Box::new(ClosureBehaviour {
data: (SmoothKeyframes::new(vec![(1.0, 0.2), (2.0, 0.7)]), 0.01),
process: |data, params, time, _scene, _abs_position| {
params.position.x = data.0.get_value(time);
},
shader: |_data, _frame, uv, _time, _abs_position| -> Rgba<u8> {
let p = uv.map_both(|v| (v * 255.0) as u8);
Rgba([255, p.x, p.y, 255])
},
}))
.build()
.unwrap();
Scene::builder()
.with_length(Duration::from_secs(10))
.with_resolution(RESOLUTION_720P)
.with_fps(30)
.add_child(main_renderable)
.build()
.change_context(MainError)
.attach_printable_lazy(|| "Failed to create scene")?
.render()
.change_context(MainError)
}sourcepub fn with_size(&mut self, x: f64, y: f64) -> &mut Self
pub fn with_size(&mut self, x: f64, y: f64) -> &mut Self
Examples found in repository?
examples/keyframed_gradient.rs (line 14)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() -> Result<(), MainError> {
let main_renderable = Renderable::builder()
.with_position(0.2, 0.1)
.with_size(0.3, 0.3)
.with_rotation(2.0)
.with_behaviour(Box::new(ClosureBehaviour {
data: (SmoothKeyframes::new(vec![(1.0, 0.2), (2.0, 0.7)]), 0.01),
process: |data, params, time, _scene, _abs_position| {
params.position.x = data.0.get_value(time);
},
shader: |_data, _frame, uv, _time, _abs_position| -> Rgba<u8> {
let p = uv.map_both(|v| (v * 255.0) as u8);
Rgba([255, p.x, p.y, 255])
},
}))
.build()
.unwrap();
Scene::builder()
.with_length(Duration::from_secs(10))
.with_resolution(RESOLUTION_720P)
.with_fps(30)
.add_child(main_renderable)
.build()
.change_context(MainError)
.attach_printable_lazy(|| "Failed to create scene")?
.render()
.change_context(MainError)
}sourcepub fn with_behaviour(&mut self, behaviour: Box<dyn Behaviour>) -> &mut Self
pub fn with_behaviour(&mut self, behaviour: Box<dyn Behaviour>) -> &mut Self
Examples found in repository?
examples/keyframed_gradient.rs (lines 16-25)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() -> Result<(), MainError> {
let main_renderable = Renderable::builder()
.with_position(0.2, 0.1)
.with_size(0.3, 0.3)
.with_rotation(2.0)
.with_behaviour(Box::new(ClosureBehaviour {
data: (SmoothKeyframes::new(vec![(1.0, 0.2), (2.0, 0.7)]), 0.01),
process: |data, params, time, _scene, _abs_position| {
params.position.x = data.0.get_value(time);
},
shader: |_data, _frame, uv, _time, _abs_position| -> Rgba<u8> {
let p = uv.map_both(|v| (v * 255.0) as u8);
Rgba([255, p.x, p.y, 255])
},
}))
.build()
.unwrap();
Scene::builder()
.with_length(Duration::from_secs(10))
.with_resolution(RESOLUTION_720P)
.with_fps(30)
.add_child(main_renderable)
.build()
.change_context(MainError)
.attach_printable_lazy(|| "Failed to create scene")?
.render()
.change_context(MainError)
}pub fn with_scale(&mut self, x: f64, y: f64) -> &mut Self
sourcepub fn with_rotation(&mut self, rotation: f64) -> &mut Self
pub fn with_rotation(&mut self, rotation: f64) -> &mut Self
Examples found in repository?
examples/keyframed_gradient.rs (line 15)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() -> Result<(), MainError> {
let main_renderable = Renderable::builder()
.with_position(0.2, 0.1)
.with_size(0.3, 0.3)
.with_rotation(2.0)
.with_behaviour(Box::new(ClosureBehaviour {
data: (SmoothKeyframes::new(vec![(1.0, 0.2), (2.0, 0.7)]), 0.01),
process: |data, params, time, _scene, _abs_position| {
params.position.x = data.0.get_value(time);
},
shader: |_data, _frame, uv, _time, _abs_position| -> Rgba<u8> {
let p = uv.map_both(|v| (v * 255.0) as u8);
Rgba([255, p.x, p.y, 255])
},
}))
.build()
.unwrap();
Scene::builder()
.with_length(Duration::from_secs(10))
.with_resolution(RESOLUTION_720P)
.with_fps(30)
.add_child(main_renderable)
.build()
.change_context(MainError)
.attach_printable_lazy(|| "Failed to create scene")?
.render()
.change_context(MainError)
}sourcepub fn build(&mut self) -> Result<Renderable, RenderableBuilderError>
pub fn build(&mut self) -> Result<Renderable, RenderableBuilderError>
Examples found in repository?
examples/keyframed_gradient.rs (line 26)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() -> Result<(), MainError> {
let main_renderable = Renderable::builder()
.with_position(0.2, 0.1)
.with_size(0.3, 0.3)
.with_rotation(2.0)
.with_behaviour(Box::new(ClosureBehaviour {
data: (SmoothKeyframes::new(vec![(1.0, 0.2), (2.0, 0.7)]), 0.01),
process: |data, params, time, _scene, _abs_position| {
params.position.x = data.0.get_value(time);
},
shader: |_data, _frame, uv, _time, _abs_position| -> Rgba<u8> {
let p = uv.map_both(|v| (v * 255.0) as u8);
Rgba([255, p.x, p.y, 255])
},
}))
.build()
.unwrap();
Scene::builder()
.with_length(Duration::from_secs(10))
.with_resolution(RESOLUTION_720P)
.with_fps(30)
.add_child(main_renderable)
.build()
.change_context(MainError)
.attach_printable_lazy(|| "Failed to create scene")?
.render()
.change_context(MainError)
}Auto Trait Implementations§
impl !RefUnwindSafe for RenderableBuilder
impl Send for RenderableBuilder
impl Sync for RenderableBuilder
impl Unpin for RenderableBuilder
impl !UnwindSafe for RenderableBuilder
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