[][src]Struct rustbatch::render::particle::shapes::SymmetricShape

pub struct SymmetricShape { /* fields omitted */ }

SymmetricShape is used for drawing shapes like triangles rectangles all the way to circles, it depends on how many edges you specify. Note that this is not at all more effective then drawing sprite with that shape and also you have to use no_texture batch. It gives you option to draw with whatever color you want. You can even draw shape with lets say white edges and transparent center.

example

use rustbatch::{Mat, Vect, Batch, FPS, Window};
use rustbatch::math::rgba::BLACK;
use rustbatch::render::particle::shapes::SymmetricShape;
fn main() {

    use rustbatch::rgba::WHITE;
let (mut window, mut event_pump, _gl, _s, _e) = Window::new(|sys| {
        sys.window("heureka", 1000, 600)
            .opengl()
            .resizable()
            .build()
            .unwrap()
    });

    window.set_background_color(&[0.5f32, 0.5f32, 0.5f32, 1f32]);

    //creating shape with 10 edges
    let mut shape = SymmetricShape::new(10, 0f32);

    //this is important, you have to use no texture batch to use shapes in it
    let mut batch = Batch::no_texture();

    let mut fps = FPS::new(1f32);

    'main: loop {
        //polling events
        for event in event_pump.poll_iter() {
            match event {
                sdl2::event::Event::Quit { .. } => break 'main,
                _ => {}
            }
        }

        let delta = fps.increase(0f32);

        window.clear();

        shape.draw(&mut batch, &Mat::IM.scaled(Vect::ZERO, 100f32), &WHITE, &BLACK);

        batch.draw(&mut window.canvas);


        batch.clear();

        window.update();
    }
}

Implementations

impl SymmetricShape[src]

pub fn new(edges: usize, rotation: f32) -> SymmetricShape[src]

new is shape constructor

pub fn draw<T: Target>(
    &mut self,
    target: &mut T,
    transform: &Mat,
    inner_color: &RGBA,
    outer_color: &RGBA
)
[src]

draw draws shape to batch, batch has to be no_texture batch otherwise this triggers panic. See batch functions to how to make no_texture batch.

Trait Implementations

impl Clone for SymmetricShape[src]

impl Particle for SymmetricShape[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,