use std::marker::PhantomData;
use plotters_backend::BackendCoord;
pub trait Orientation<K, V> {
type XType;
type YType;
fn make_coord(key: K, val: V) -> (Self::XType, Self::YType);
fn with_offset(coord: BackendCoord, offset: i32) -> BackendCoord;
}
pub struct Vertical<K, V>(PhantomData<(K, V)>);
pub struct Horizontal<K, V>(PhantomData<(K, V)>);
impl<K, V> Orientation<K, V> for Vertical<K, V> {
type XType = K;
type YType = V;
fn make_coord(key: K, val: V) -> (K, V) {
(key, val)
}
fn with_offset(coord: BackendCoord, offset: i32) -> BackendCoord {
(coord.0 + offset, coord.1)
}
}
impl<K, V> Orientation<K, V> for Horizontal<K, V> {
type XType = V;
type YType = K;
fn make_coord(key: K, val: V) -> (V, K) {
(val, key)
}
fn with_offset(coord: BackendCoord, offset: i32) -> BackendCoord {
(coord.0, coord.1 + offset)
}
}