Remove cl-format usage from cursors.

This commit is contained in:
Andrey Antukh 2020-11-25 19:51:01 +01:00 committed by Hirunatan
parent 5a17237015
commit 1d08bac493
2 changed files with 27 additions and 28 deletions

View file

@ -8,11 +8,10 @@
;; Copyright (c) 2020 UXBOX Labs SL
(ns app.main.ui.cursors
(:import java.net.URLEncoder)
(:require [rumext.alpha]
[clojure.java.io :as io]
[lambdaisland.uri.normalize :as uri]
[cuerdas.core :as str]))
(:require
[clojure.java.io :as io]
[cuerdas.core :as str]
[lambdaisland.uri.normalize :as uri]))
(def cursor-folder "images/cursors")
@ -55,22 +54,18 @@
(defn encode-svg-cursor
[id rotation x y height]
(let [svg-path (str cursor-folder "/" (name id) ".svg")
data (-> svg-path io/resource slurp parse-svg uri/percent-encode)
transform (if rotation (str " transform='rotate(" rotation ")'") "")
data (clojure.pprint/cl-format
nil
"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='20px' height='~Apx'~A%3E~A%3C/svg%3E\") ~A ~A, auto"
height transform data x y )]
data))
(let [svg-path (str cursor-folder "/" (name id) ".svg")
data (-> svg-path io/resource slurp parse-svg uri/percent-encode)
transform (if rotation (str " transform='rotate(" rotation ")'") "")]
(str "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='20px' "
"height='" height "px' " transform "%3E" data "%3C/svg%3E\") " x " " y ", auto")))
(defmacro cursor-ref
"Creates a static cursor given its name, rotation and x/y hotspot"
([id] (encode-svg-cursor id default-rotation default-hotspot-x default-hotspot-y default-height))
([id rotation] (encode-svg-cursor id rotation default-hotspot-x default-hotspot-y default-height))
([id rotation x y] (encode-svg-cursor id rotation x y default-height))
([id rotation x y height] (encode-svg-cursor id rotation x y height))
)
([id rotation x y height] (encode-svg-cursor id rotation x y height)))
(defmacro cursor-fn
"Creates a dynamic cursor that can be rotated in runtime"