aboutsummaryrefslogtreecommitdiff
path: root/src/bitmap.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-04-04 11:09:17 +0100
committerAkshay <[email protected]>2021-04-04 14:07:09 +0100
commitc4354e2d8d51cc9fc12dce9ad2d5736e400a8de4 (patch)
treea651a7d2406886869be693baa7afbd7807fdfa0f /src/bitmap.rs
parent62d9de6a368a50dcb62b2b97a5fb02a3858b0977 (diff)
basic support for adding guides
Diffstat (limited to 'src/bitmap.rs')
-rw-r--r--src/bitmap.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/bitmap.rs b/src/bitmap.rs
index 2bf8556..8010a4b 100644
--- a/src/bitmap.rs
+++ b/src/bitmap.rs
@@ -4,6 +4,8 @@ use std::{
4 ops::{Add, Sub}, 4 ops::{Add, Sub},
5}; 5};
6 6
7use crate::lisp::{error::EvalError, expr::LispExpr};
8
7#[derive(Debug)] 9#[derive(Debug)]
8pub struct Pixmap<T> { 10pub struct Pixmap<T> {
9 pub width: u32, 11 pub width: u32,
@@ -71,12 +73,38 @@ impl Sub for MapPoint {
71 } 73 }
72} 74}
73 75
74#[derive(Debug, Copy, Clone)] 76#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
75pub enum Axis { 77pub enum Axis {
76 X, 78 X,
77 Y, 79 Y,
78} 80}
79 81
82impl Into<LispExpr> for Axis {
83 fn into(self) -> LispExpr {
84 LispExpr::Quote(
85 Box::new(LispExpr::Ident(match self {
86 Self::X => "X".into(),
87 Self::Y => "Y".into(),
88 })),
89 1,
90 )
91 }
92}
93
94impl TryFrom<&LispExpr> for Axis {
95 type Error = EvalError;
96 fn try_from(value: &LispExpr) -> Result<Self, Self::Error> {
97 match value {
98 LispExpr::Ident(id) => match id.as_ref() {
99 "x" => Ok(Axis::X),
100 "y" => Ok(Axis::Y),
101 _ => Err(EvalError::TypeMismatch),
102 },
103 _ => Err(EvalError::TypeMismatch),
104 }
105 }
106}
107
80#[derive(Debug, Copy, Clone)] 108#[derive(Debug, Copy, Clone)]
81pub enum Quadrant { 109pub enum Quadrant {
82 I, 110 I,