mirror of
https://github.com/penpot/penpot.git
synced 2025-07-22 16:57:15 +02:00
commit
50eee3f597
6 changed files with 60 additions and 13 deletions
|
@ -8,6 +8,7 @@
|
|||
"Color conversion utils."
|
||||
(:require
|
||||
[app.util.object :as obj]
|
||||
[app.util.strings :as ust]
|
||||
[cuerdas.core :as str]
|
||||
[goog.color :as gcolor]))
|
||||
|
||||
|
@ -55,6 +56,14 @@
|
|||
(-> (hex->hsl data)
|
||||
(conj opacity)))
|
||||
|
||||
(defn format-hsla
|
||||
[[h s l a]]
|
||||
(let [precision 2
|
||||
rounded-s (* 100 (ust/format-precision s precision))
|
||||
rounded-l (* 100 (ust/format-precision l precision))]
|
||||
|
||||
(str/fmt "%s, %s%, %s%, %s" h rounded-s rounded-l a)))
|
||||
|
||||
(defn hsl->rgb
|
||||
[[h s l]]
|
||||
(gcolor/hslToRgb h s l))
|
||||
|
@ -116,9 +125,9 @@
|
|||
|
||||
stops-css (str/join "," (map parse-stop stops))]
|
||||
|
||||
(if (= type :linear)
|
||||
(str/fmt "linear-gradient(to bottom, %s)" stops-css)
|
||||
(str/fmt "radial-gradient(circle, %s)" stops-css))))
|
||||
(if (= type :linear)
|
||||
(str/fmt "linear-gradient(to bottom, %s)" stops-css)
|
||||
(str/fmt "radial-gradient(circle, %s)" stops-css))))
|
||||
|
||||
;; TODO: REMOVE `VALUE` WHEN COLOR IS INTEGRATED
|
||||
(defn color->background [{:keys [color opacity gradient value]}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue