/
model_geom.clj
52 lines (47 loc) · 1.5 KB
/
model_geom.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
(ns js.react-native.model-geom
(:require [std.lang :as l]
[std.lib :as h]))
(l/script :js
{:runtime :websocket
:config {:id :play/web-main
:bench false
:emit {:native {:suppress true}
:lang/jsx false}
:notify {:host "test.statstrade.io"}}
:require [[xt.lang.base-lib :as k]]
:export [MODULE]})
(def.js POSITION
{"top" {:opposite "bottom"
:sides ["left" "right"]}
"bottom" {:opposite "top"
:sides ["right" "left"]}
"left" {:opposite "right"
:sides ["bottom" "top"]}
"right" {:opposite "left"
:sides ["top" "bottom"]}})
(defn.js oppositePosition
"gets the opposite position"
{:added "4.0"}
[position]
(return (k/get-in -/POSITION [position "opposite"])))
(defn.js triangleBaseStyle
"constructs a style for triangle"
{:added "4.0"}
[color point baseLength baseHeight]
(var #{opposite
sides} (k/get-key -/POSITION point))
(var [s0 s1] sides)
(var Point (k/capitalize point))
(var Opposite (k/capitalize opposite))
(var S0 (k/capitalize s0))
(var S1 (k/capitalize s1))
(return
{(+ "border" Point "Width") 0
(+ "border" Opposite "Width") baseHeight
(+ "border" S0 "Width") (* baseLength 0.5)
(+ "border" S1 "Width") (* baseLength 0.5)
(+ "border" Point "Color") "transparent"
(+ "border" Opposite "Color") color
(+ "border" S0 "Color") "transparent"
(+ "border" S1 "Color") "transparent"}))
(def.js MODULE (!:module))