/
Point.purs
100 lines (93 loc) · 3.45 KB
/
Point.purs
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
module Mathbox.Class.Draw.Point where
import Prelude (map, ($))
import Data.Maybe (Maybe(Nothing))
import Data.Nullable (Nullable, toNullable)
import Mathbox.Field
import Mathbox.Types as T
type PointG a b =
{ id :: b String
, classes :: a T.Classes
, visible :: a T.Bool
, opacity :: a Number
, color :: a T.Color
, blending :: a T.Blending
, zWrite :: a T.Bool
, zTest :: a T.Bool
, zIndex :: a T.Round
, zBias :: a Number
, zOrder :: b Int
, size :: a Number
, sizes :: b T.Select
, shape :: a T.Shape
, optical :: a T.Bool
, fill :: a T.Bool
, depth :: a Number
, points :: a T.Select
, colors :: b T.Select
}
type Point = PointG Field MaybeField
type JsPoint =
{ id :: Nullable (Field String)
, classes :: Field T.JsClasses
, visible :: Field T.Bool
, opacity :: Field Number
, color :: Field T.JsColor
, blending :: Field T.JsBlending
, zWrite :: Field T.Bool
, zTest :: Field T.Bool
, zIndex :: Field T.JsRound
, zBias :: Field Number
, zOrder :: Nullable (Field Int)
, size :: Field Number
, sizes :: Nullable (Field T.JsSelect)
, shape :: Field T.JsShape
, optical :: Field T.Bool
, fill :: Field T.Bool
, depth :: Field Number
, points :: Field T.JsSelect
, colors :: Nullable (Field T.JsSelect)
}
mkPoint :: Point
mkPoint =
{ id : Nothing
, classes : Val $ T.mkClasses0
, visible : Val $ true
, opacity : Val $ 1.0
, color : Val $ T.mkColor0
, blending : Val $ T.mkBlending0
, zWrite : Val $ true
, zTest : Val $ true
, zIndex : Val $ T.mkRound0
, zBias : Val $ 0.0
, zOrder : Nothing
, size : Val $ 4.0
, sizes : Nothing
, shape : Val $ T.mkShape0
, optical : Val $ true
, fill : Val $ true
, depth : Val $ 1.0
, points : Val $ T.mkSelect0
, colors : Nothing
}
pointToJs :: Point -> JsPoint
pointToJs p =
{ id : toNullable p.id
, classes : map T.classesToJs p.classes
, visible : p.visible
, opacity : p.opacity
, color : map T.colorToJs p.color
, blending : map T.blendingToJs p.blending
, zWrite : p.zWrite
, zTest : p.zTest
, zIndex : map T.roundToJs p.zIndex
, zBias : p.zBias
, zOrder : toNullable p.zOrder
, size : p.size
, sizes : maybeToNullable T.selectToJs p.sizes
, shape : map T.shapeToJs p.shape
, optical : p.optical
, fill : p.fill
, depth : p.depth
, points : map T.selectToJs p.points
, colors : maybeToNullable T.selectToJs p.colors
}