processing/shapes/
mould.rs

1use glium::uniforms::Uniforms;
2
3use shaders::ShaderInfo;
4use shapes::Shape;
5
6/// A Mould is a Shape that has been paired with a custom shader. This is useful when
7/// you want to modify the way a few shapes are drawn, without completely altering 
8/// the standard `processing-rs` rendering state. The concept was borrowed from
9/// libCinder.
10pub struct Mould<U: Uniforms, S: Shape> {
11    shape: S,
12    shader: ShaderInfo<U>,
13}
14
15impl<U: Uniforms, S: Shape> Mould<U, S> {
16    pub fn new(shape: S, shader: ShaderInfo<U>) -> Self {
17        Mould {
18            shape: shape,
19            shader: shader,
20        }
21    }
22
23    pub fn get_shape(&self) -> &S {
24        &self.shape
25    }
26
27    pub fn get_shader(&self) -> &ShaderInfo<U> {
28        &self.shader
29    }
30
31    pub fn set(&mut self, uniforms: U) {
32        self.shader.set(uniforms)
33    }
34}