generated from Phlox-GL/phlox-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompact.cirru
148 lines (147 loc) · 5.68 KB
/
compact.cirru
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{} (:package |app)
:configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!)
:modules $ [] |memof/ |lilac/ |respo.calcit/ |respo-ui.calcit/ |phlox/
:version |0.4.10
:entries $ {}
:files $ {}
|app.comp.container $ {}
:ns $ quote
ns app.comp.container $ :require
phlox.core :refer $ g hslx rect circle text container graphics create-list >>
phlox.comp.button :refer $ comp-button
phlox.comp.drag-point :refer $ comp-drag-point
respo-ui.core :as ui
memof.alias :refer $ memof-call
phlox.complex :as complex
:defs $ {}
|comp-container $ quote
defn comp-container (store)
; println "\"Store" store $ :tab store
let
cursor $ []
states $ :states store
container ({})
comp-spiral $ {}
|comp-cloud $ quote
defn comp-cloud (options)
graphics $ {}
:ops $ []
g :line-style $ {} (:width 3) (:alpha 1)
:color $ hslx 260 100 92
g :move-to $ [] 0 0
, &
-> (range 20 250)
map $ fn (idx)
let
angle $ * -0.1 idx
r $ * 0.13 idx
g :line-to $ []
* r $ cos angle
* r $ sin angle
:alpha 0.2
:position $ :position options
|comp-spiral $ quote
defn comp-spiral (options)
graphics $ {}
:ops $ let
trail $ gen-spiral-trail 20 600
[]
g :line-style $ {} (:width 3) (:alpha 1)
:color $ hslx 260 100 70
g :move-to $ first trail
, & $ -> trail rest
map $ fn (p) (g :line-to p)
:alpha 0.2
:position $ :position options
|gen-spiral-trail $ quote
defn gen-spiral-trail (from to)
-> (range from to)
map $ fn (idx)
let
angle $ * 0.03 idx
r $ * 0.6 idx
angle2 $ * 6 angle
r2 60
complex/add
[]
* r $ cos angle
* r $ sin angle
[]
* r2 $ cos angle2
* r2 $ sin angle2
|app.schema $ {}
:ns $ quote (ns app.schema)
:defs $ {}
|store $ quote
def store $ {} (:tab :drafts) (:x 0) (:keyboard-on? false) (:counted 0)
:states $ {}
:cursor $ []
|app.updater $ {}
:ns $ quote
ns app.updater $ :require
[] phlox.cursor :refer $ [] update-states
:defs $ {}
|updater $ quote
defn updater (store op op-data op-id op-time)
case-default op
do (println "\"unknown op" op op-data) store
:add-x $ update store :x
fn (x)
if (> x 10) 0 $ + x 1
:tab $ assoc store :tab op-data
:toggle-keyboard $ update store :keyboard-on? not
:counted $ update store :counted inc
:states $ update-states store op-data
:hydrate-storage op-data
|app.main $ {}
:ns $ quote
ns app.main $ :require ("\"pixi.js" :as PIXI)
phlox.core :refer $ render! clear-phlox-caches!
app.comp.container :refer $ comp-container
app.schema :as schema
app.config :refer $ dev?
"\"nanoid" :refer $ nanoid
app.updater :refer $ updater
"\"fontfaceobserver-es" :as FontFaceObserver
"\"./calcit.build-errors" :default build-errors
"\"bottom-tip" :default hud!
:defs $ {}
|render-app! $ quote
defn render-app! (? arg)
render! (comp-container @*store) dispatch! $ or arg
{} $ :background-alpha 0
|main! $ quote
defn main! () (; js/console.log PIXI)
if dev? $ load-console-formatter!
-> (new FontFaceObserver/default "\"Josefin Sans") (.!load)
.!then $ fn (event) (render-app!)
add-watch *store :change $ fn (store prev) (render-app!)
set! (.-resize js/window.addEventListener)
fn (event) (render-app!)
println "\"App Started"
|*store $ quote (defatom *store schema/store)
|dispatch! $ quote
defn dispatch! (op op-data)
when
and dev? $ not= op :states
println "\"dispatch!" op op-data
let
op-id $ nanoid
op-time $ js/Date.now
reset! *store $ updater @*store op op-data op-id op-time
|reload! $ quote
defn reload! () $ if (nil? build-errors)
do (println "\"Code updated.") (clear-phlox-caches!) (remove-watch *store :change)
add-watch *store :change $ fn (store prev) (render-app!)
set! (.-resize js/window.addEventListener)
fn (event) (render-app!)
render-app!
hud! "\"ok~" "\"Ok"
hud! "\"error" build-errors
|app.config $ {}
:ns $ quote (ns app.config)
:defs $ {}
|dev? $ quote
def dev? $ = "\"dev" (get-env "\"mode")
|site $ quote
def site $ {} (:dev-ui "\"http://localhost:8100/main.css") (:release-ui "\"http://cdn.tiye.me/favored-fonts/main.css") (:cdn-url "\"http://cdn.tiye.me/phlox/") (:title "\"Phlox") (:icon "\"http://cdn.tiye.me/logo/quamolit.png") (:storage-key "\"phlox")