pub struct RenderableBuilder { /* private fields */ }

Implementations§

source§

impl RenderableBuilder

source

pub fn add_child(&mut self, child: Renderable) -> &mut Self

source

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)
}
source

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)
}
source

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)
}
source

pub fn with_scale(&mut self, x: f64, y: f64) -> &mut Self

source

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)
}
source

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§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.