renderbug: first implementation of virtual coordinate based rendering

This commit is contained in:
2024-10-27 15:14:28 +01:00
parent 4432ba7ad0
commit 3f20c07369
6 changed files with 221 additions and 97 deletions

53
src/geometry.rs Normal file
View File

@ -0,0 +1,53 @@
use std::marker::PhantomData;
pub trait CoordinateSpace {}
pub trait Coordinates<T, S: CoordinateSpace> {
fn x(&self) -> T;
fn y(&self) -> T;
fn new(x: T, y: T) -> Self;
const MAX: T;
const MIN: T;
}
#[derive(PartialEq, Debug, Copy, Clone)]
pub struct Virtual {}
impl CoordinateSpace for Virtual {}
#[derive(PartialEq, Debug, Copy, Clone)]
pub struct Physical {}
impl CoordinateSpace for Physical {}
#[derive(PartialEq, Debug, Copy, Clone)]
pub struct Coord8<S: CoordinateSpace> {
x: u8,
y: u8,
space: PhantomData<S>
}
pub type VirtualCoordinates = Coord8<Virtual>;
pub type PhysicalCoordinates = Coord8<Physical>;
impl<S> Coordinates<u8, S> for Coord8<S>
where
S: CoordinateSpace {
fn new(x: u8, y: u8) -> Self {
Self {
x: x,
y: y,
space: PhantomData
}
}
fn x(&self) -> u8 {
self.x
}
fn y(&self) -> u8 {
self.y
}
const MAX: u8 = 255;
const MIN: u8 = 255;
}