Maraiah/source/rozinante/draw.rs

31 lines
617 B
Rust
Raw Normal View History

2019-03-02 21:45:04 -08:00
//! GUI drawing capabilities.
use crate::durandal::image::Color;
2019-03-02 15:26:55 -08:00
2019-03-02 17:49:35 -08:00
pub trait CacheImage
{
fn w(&self) -> Coord;
fn h(&self) -> Coord;
}
2019-03-02 15:26:55 -08:00
pub trait DrawArea
{
2019-03-02 17:49:35 -08:00
type NativeImage: CacheImage;
fn w(&self) -> Coord;
fn h(&self) -> Coord;
2019-03-02 15:26:55 -08:00
fn clear(&self, cr: impl Color);
fn rect(&self, rect: Rect, cr: impl Color);
2019-03-02 21:45:04 -08:00
fn text(&self, pos: Point, text: &str, cr: impl Color);
2019-03-02 17:49:35 -08:00
fn image(&self, pos: Point, im: &Self::NativeImage);
2019-03-02 15:26:55 -08:00
}
2019-03-02 17:49:35 -08:00
pub type Coord = i32;
pub type Point = (Coord, Coord);
2019-03-02 15:26:55 -08:00
2019-03-02 17:49:35 -08:00
#[derive(Copy, Clone, Debug)]
pub struct Rect {pub x: Coord, pub y: Coord, pub w: Coord, pub h: Coord}
2019-03-02 15:26:55 -08:00
// EOF