File tree 2 files changed +17
-24
lines changed
2 files changed +17
-24
lines changed Original file line number Diff line number Diff line change 2
2
:deps {akiroz.re-frame/storage {:mvn/version " 0.1.4" }
3
3
binaryage/devtools {:mvn/version " 1.0.7" }
4
4
camel-snake-kebab/camel-snake-kebab {:mvn/version " 0.4.3" }
5
- cljs-ajax/cljs-ajax {:mvn/version " 0.8.4" }
6
5
clj-kdtree/clj-kdtree {:git/url " https://github.com/abscondment/clj-kdtree.git"
7
6
:sha " 5ec321c5e8006db00fa8b45a8ed9eb0b8f3dd56d"
8
7
:deps/manifest :deps }
Original file line number Diff line number Diff line change 1
1
(ns user
2
2
(:require
3
- [ajax.core]
4
3
[clojure.math]
5
4
[clojure.string :as str]
6
5
[config :as config]
318
317
319
318
(def ^:export version config /version )
320
319
321
- #_{:clj-kondo/ignore [:unresolved-var ]}
322
320
(comment
323
321
(dotimes [x 25 ]
324
322
(circle [(+ (* x 30 ) 40 ) (+ (* (js/Math.sin x) 10 ) 200 )]
325
323
10
326
324
{:fill (str " hsl(" (* x 10 ) " ,50% , 50%)" )}))
327
325
328
- (ajax.core/GET
329
- " https://api.thecatapi.com/v1/images/search"
330
- {:response-format (ajax.core/json-response-format {:keywords? true })
331
- :handler (fn [response]
332
- (let [{:keys [width height url]} (first response)]
333
- (image 0 0 [width height] url)))})
334
-
335
- (defn kitty [x y width height]
336
- (ajax.core/GET
337
- " https://api.thecatapi.com/v1/images/search"
338
- {:response-format (ajax.core/json-response-format {:keywords? true })
339
- :handler (fn [response]
340
- (image [x y]
341
- width
342
- height
343
- (:url (first response))
344
- {:preserveAspectRatio " xMidYMid slice" }))}))
345
-
346
- (dotimes [x 8 ]
347
- (dotimes [y 6 ]
348
- (kitty (* x 100 ) (* y 100 ) 100 100 ))))
326
+ (defn ^:export kitty [[x y] width height]
327
+ (-> (js/fetch " https://api.thecatapi.com/v1/images/search" #js{:method " GET" })
328
+ (.then (fn [response]
329
+ (-> (.json response)
330
+ (.then (fn [body]
331
+ (let [body (js->clj body :keywordize-keys true )]
332
+ (image [x y]
333
+ width
334
+ height
335
+ (:url (first body))
336
+ {:preserveAspectRatio " xMidYMid slice" })))))))))
337
+
338
+ (dotimes [x 5 ]
339
+ (dotimes [y 5 ]
340
+ (kitty [(* x 100 ) (* y 100 )] 100 100 )))
341
+
342
+ #())
You can’t perform that action at this time.
0 commit comments