use Matrix;
pub trait Draw {
type ImageResource: ?Sized;
type TextStyle: ?Sized;
fn draw_triangle(&mut self, texture: &Self::ImageResource, matrix: &Matrix,
uv_coords: [[f32; 2]; 3]);
#[inline]
fn draw_image(&mut self, name: &Self::ImageResource, matrix: &Matrix) {
self.draw_image_uv(name, matrix, [0.0, 1.0], [1.0, 1.0], [1.0, 0.0], [0.0, 0.0])
}
#[inline]
fn draw_image_uv(&mut self, name: &Self::ImageResource, matrix: &Matrix, top_left: [f32; 2],
top_right: [f32; 2], bottom_right: [f32; 2], bottom_left: [f32; 2])
{
self.draw_triangle(name, matrix, [top_left, bottom_left, top_right]);
let invert = Matrix::scale(-1.0);
self.draw_triangle(name, &(*matrix * invert), [bottom_right, top_right, bottom_left]);
}
fn get_image_width_per_height(&mut self, name: &Self::ImageResource) -> f32;
fn draw_glyph(&mut self, text_style: &Self::TextStyle, glyph: char, matrix: &Matrix);
fn line_height(&self, text_style: &Self::TextStyle) -> f32;
fn glyph_infos(&self, text_style: &Self::TextStyle, glyph: char) -> GlyphInfos;
fn kerning(&self, text_style: &Self::TextStyle, first_char: char, second_char: char) -> f32;
}
#[derive(Debug, Copy, Clone)]
pub struct GlyphInfos {
pub width: f32,
pub height: f32,
pub x_offset: f32,
pub y_offset: f32,
pub x_advance: f32,
}