use crate::{
types::{self, Matrix2d, Scalar},
CircleArc, DrawState, Ellipse, Image, ImageSize, Line, Polygon, Rectangle,
};
pub trait Graphics: Sized {
type Texture: ImageSize;
fn clear_color(&mut self, color: types::Color);
fn clear_stencil(&mut self, value: u8);
fn tri_list<F>(&mut self, draw_state: &DrawState, color: &[f32; 4], f: F)
where
F: FnMut(&mut dyn FnMut(&[[f32; 2]]));
fn tri_list_c<F>(&mut self, draw_state: &DrawState, f: F)
where
F: FnMut(&mut dyn FnMut(&[[f32; 2]], &[[f32; 4]]));
fn tri_list_uv<F>(
&mut self,
draw_state: &DrawState,
color: &[f32; 4],
texture: &<Self as Graphics>::Texture,
f: F,
) where
F: FnMut(&mut dyn FnMut(&[[f32; 2]], &[[f32; 2]]));
fn tri_list_uv_c<F>(
&mut self,
draw_state: &DrawState,
texture: &<Self as Graphics>::Texture,
f: F,
) where
F: FnMut(&mut dyn FnMut(&[[f32; 2]], &[[f32; 2]], &[[f32; 4]]));
#[inline(always)]
fn rectangle<R: Into<types::Rectangle>>(
&mut self,
r: &Rectangle,
rectangle: R,
draw_state: &DrawState,
transform: Matrix2d,
) {
r.draw_tri(rectangle, draw_state, transform, self);
}
#[inline(always)]
fn polygon(
&mut self,
p: &Polygon,
polygon: types::Polygon<'_>,
draw_state: &DrawState,
transform: Matrix2d,
) {
p.draw_tri(polygon, draw_state, transform, self);
}
#[inline(always)]
fn polygon_tween_lerp(
&mut self,
p: &Polygon,
polygons: types::Polygons<'_>,
tween_factor: Scalar,
draw_state: &DrawState,
transform: Matrix2d,
) {
p.draw_tween_lerp_tri(polygons, tween_factor, draw_state, transform, self);
}
#[inline(always)]
fn image(
&mut self,
image: &Image,
texture: &Self::Texture,
draw_state: &DrawState,
transform: Matrix2d,
) {
image.draw_tri(texture, draw_state, transform, self);
}
#[inline(always)]
fn ellipse<R: Into<types::Rectangle>>(
&mut self,
e: &Ellipse,
rectangle: R,
draw_state: &DrawState,
transform: Matrix2d,
) {
e.draw_tri(rectangle, draw_state, transform, self);
}
#[inline(always)]
fn line<L: Into<types::Line>>(
&mut self,
l: &Line,
line: L,
draw_state: &DrawState,
transform: Matrix2d,
) {
l.draw_tri(line, draw_state, transform, self);
}
#[inline(always)]
fn circle_arc<R: Into<types::Rectangle>>(
&mut self,
c: &CircleArc,
rectangle: R,
draw_state: &DrawState,
transform: Matrix2d,
) {
c.draw_tri(rectangle, draw_state, transform, self);
}
}