/
layer.cljc
38 lines (33 loc) · 1.11 KB
/
layer.cljc
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
(ns tile-soup.layer
(:require [clojure.spec.alpha :as s]
[tile-soup.utils :as u]
[tile-soup.properties :as properties]
[tile-soup.data :as data]))
(s/def ::id u/str->long)
(s/def ::name string?)
(s/def ::x u/str->long)
(s/def ::y u/str->long)
(s/def ::width u/str->long)
(s/def ::height u/str->long)
(s/def ::opacity u/str->float)
(s/def ::visible u/str->boolean)
(s/def ::offsetx u/str->long)
(s/def ::offsety u/str->long)
(s/def ::attrs (s/keys
:opt-un [::id
::name
::x
::y
::width
::height
::opacity
::visible
::offsetx
::offsety]))
(defmulti spec :tag)
(defmethod spec :properties [_] ::properties/properties)
(defmethod spec :data [_] ::data/data)
(defmethod spec :default [x]
(throw (ex-info (str (:tag x) " not supported in layer tags") {})))
(s/def ::content (u/conformer spec))
(s/def ::layer (s/keys :req-un [::attrs ::content]))