graphics
graphics copied to clipboard
Adds functions to `triangulation` for triangle lists
The Graphics trait takes only chunks, which is cumbersome if you have a list of triangles to render. There are some use cases, like doing experimental algorithms in scripting, which requires a simple way to feed the data to the back-end.
Both f64 and f32 precision would be nice.
@bvssvni From the docs
So currently the trait just takes a closure(Outer) as parameter which takes another closure as a parameter(Inner). Inner takes a slice of i32s, which is a chunk of the tri list. So taking the tri-list as chunks has a function signature like so:
fn tri_list<F>(&mut self, draw_state: &DrawState, color: &[f32; 4], f: F)
where F: FnMut(&mut FnMut(&[f32]));
// │ └ Inner Closure, each call to it consumes a new chunk of the tri list
// └ Outer closure, takes inner as a parameter
So what would the function signature look like in what you're describing above?
fn tri_list<F>(&mut self, draw_state: &DrawState, color: &[f32; 4], f: F)
where F: FnMut(&[f32]);
fn tri_list<F>(&mut self, draw_state: &DrawState, color: &[f32; 4], f: &[f32])
fn tri_list<F>(&mut self, draw_state: &DrawState, color: &[f32; 4], tri_list: F)
where F: FnMut() -> i32
Or are you thinking something more like having a tri-list data type that can be passed around that wraps either a reference to the closure a closure that returns chunks of the tri-list?