Struct shanimation_rs::renderable::Renderable
source · pub struct Renderable {
pub params: RenderableParams,
/* private fields */
}Fields§
§params: RenderableParamsImplementations§
source§impl Renderable
impl Renderable
pub fn clone_entire(&self) -> Self
pub fn add_child(&mut self, child: Arc<RwLock<Renderable>>)
sourcepub fn add_child_simple(&mut self, child: Renderable) -> Arc<RwLock<Renderable>>
pub fn add_child_simple(&mut self, child: Renderable) -> Arc<RwLock<Renderable>>
Creates an Arc<RwLock
pub fn get_children(&self) -> &Vec<Arc<RwLock<Renderable>>>
pub fn get_children_mut(&mut self) -> &mut Vec<Arc<RwLock<Renderable>>>
pub fn run_shader( &mut self, current_frame: &Img, uv_coords: Point<f64>, time: Duration, abs_position: Point<isize> ) -> Rgba<u8>
pub fn run_behaviour( &mut self, time: Duration, scene: &Scene, abs_position: Point<isize> )
sourcepub fn builder() -> RenderableBuilder
pub fn builder() -> RenderableBuilder
Examples found in repository?
examples/keyframed_gradient.rs (line 12)
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)
}Trait Implementations§
source§impl Clone for Renderable
impl Clone for Renderable
source§fn clone(&self) -> Renderable
fn clone(&self) -> Renderable
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Renderable
impl Send for Renderable
impl Sync for Renderable
impl Unpin for Renderable
impl !UnwindSafe for Renderable
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