mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 20:41:37 +02:00
🐛 Fix SVG text rendering on thumbnails
This commit is contained in:
parent
7b887d3188
commit
a72e50f674
4 changed files with 63 additions and 10 deletions
29
frontend/src/app/util/thumbnails.cljs
Normal file
29
frontend/src/app/util/thumbnails.cljs
Normal file
|
@ -0,0 +1,29 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.util.thumbnails
|
||||
(:require
|
||||
[app.common.math :as mth]))
|
||||
|
||||
(def ^:const min-size 250)
|
||||
(def ^:const max-size 2000)
|
||||
|
||||
(defn get-proportional-size
|
||||
"Returns a proportional size given a width and height and some size constraints."
|
||||
([width height]
|
||||
(get-proportional-size width height min-size max-size min-size max-size))
|
||||
([width height min-size max-size]
|
||||
(get-proportional-size width height min-size max-size min-size max-size))
|
||||
([width height min-width max-width min-height max-height]
|
||||
(let [[fixed-width fixed-height]
|
||||
(if (> width height)
|
||||
[(mth/clamp width min-width max-width)
|
||||
(/ (* height (mth/clamp width min-width max-width)) width)]
|
||||
[(/ (* width (mth/clamp height min-height max-height)) height)
|
||||
(mth/clamp height min-height max-height)])]
|
||||
[fixed-width fixed-height])))
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue