-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.clj
78 lines (61 loc) · 1.29 KB
/
schema.clj
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
(ns mirror.schema)
(def max-x 20967)
(def X [:int {:min 0 :max max-x}])
(def max-y 15725)
(def Y [:int {:min 0 :max max-y}])
(def Point
[:tuple #'X #'Y])
(def Event
[:map
[:x {:optional true} #'X]
[:y {:optional true} #'Y]
[:pres {:optional true} int?]
[:pen {:optional true} [:enum 0 1]]
[:rubber {:optional true} [:enum 0 1]]
[:touch {:optional true} [:enum 0 1]]])
(def Line
[:map
[:type [:enum :pen :rubber]]
[:points [:vector #'Point]]])
(def State
[:map
[:lines [:vector #'Line]]
[:current-point #'Point]
[:current-line #'Line]
[:in-line? boolean]])
(comment
(require
'[malli.core :as m]
'[malli.generator :as mg])
(mg/generate X)
;; => 11653
(mg/generate Y)
;; => 53
(mg/generate Point)
;; => {:x 15496, :y 1365}
(mg/generate Line)
;; => {:type :pen,
;; :points
;; [[507 14228]
;; [6906 1]
;; [13 9966]
;; [4 890]
;; [12480 8402]
;; [11910 115]
;; [4 2]
;; [2 9472]
;; [15821 12392]
;; [12061 13336]
;; [11774 10081]
;; [352 191]
;; [19985 60]
;; [15741 5961]
;; [1076 14937]
;; [16159 12174]
;; [18198 4]
;; [529 1257]
;; [14352 8352]
;; [0 8952]
;; [2 15540]]}
;;
)