-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommon.hs
76 lines (59 loc) · 2.36 KB
/
Common.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
-- ========================================
-- ===== Definición de tipos de datos =====
-- ========================================
module Common where
-- Tipos para polígonos desde línea de comando --
-------------------------------------------------
type MyPoint = (Float, Float)
data Polygon = P {p :: [MyPoint],
pn :: String} deriving (Eq, Show)
type Polygons = [Polygon]
-- Representamos un rectángulo de acuerdo a su diagonal "de izquierda a derecha, de abajo hacia arriba".
-- Es decir, con un vector del cuadrante I.
-- El int representa el id del rectángulo.
data Container = C {p1x :: Float,
p1y :: Float,
p2x :: Float,
p2y :: Float,
nc :: String,
rid :: Int} deriving (Eq, Show)
instance Ord Container where
x <= y = rid x <= rid y
type Containers = [Container]
data Def = Dc Container Float
| Dp Polygon Float -- ID (solo para el usuario), def. del polígono y escalamiento
deriving Show
data Machine = Kerf Float [Def] deriving Show
-- Tipos para archivos SVG --
-----------------------------
data Transform = Scale Float
| SkewX Float
| SkewY Float
| Matrix Float Float Float Float Float Float
| Thrash
deriving Show
data Rect = Rect {w :: Float,
h :: Float,
tr :: [Transform],
nr :: String} deriving Show
data SVGPolygon = Pol {po :: [MyPoint],
tpo :: [Transform],
npo :: String} deriving Show
data PathCommand = M_rel MyPoint
| M_abs MyPoint
| H_rel Float
| H_abs Float
| V_rel Float
| V_abs Float
| L_rel MyPoint
| L_abs MyPoint
| Complete MyPoint -- Usado para los espacios sin completar
| Z
deriving Show
data Path = Path {pa :: [PathCommand],
tpa :: [Transform],
npa :: String} deriving Show
data SVG = SVGR Rect
| SVGPo SVGPolygon
| SVGPa Path
deriving Show