<commit_before>;; 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/.
;;
;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0.
;;
;; Copyright (c) 2020 UXBOX Labs SL

(ns uxbox.main.ui.workspace.shapes.outline
  (:require
   [rumext.alpha :as mf]
   [uxbox.common.geom.shapes :as gsh]
   [uxbox.util.object :as obj]
   [rumext.util :refer [map->obj]]
   [uxbox.main.ui.shapes.path :as path]))


(mf/defc outline
  {::mf/wrap-props false}
  [props]
  (let [shape (unchecked-get props "shape")
        transform (gsh/transform-matrix shape)
        {:keys [id x y width height]} shape

        outline-type (case (:type shape)
                       :circle "ellipse"
                       (:curve :path) "path"
                       "rect")

        common {:fill "transparent"
                :stroke "#31EFB8"
                :strokeWidth "1px"
                :pointerEvents "none"
                :transform transform}

        props (case (:type shape)
                :circle
                {:cx (+ x (/ width 2))
                 :cy (+ y (/ height 2))
                 :rx (/ width 2)
                 :ry (/ height 2)}
                
                (:curve :path)
                {:d (path/render-path shape)}
                
                {:x x
                 :y y
                 :width width
                 :height height})]

    [:> outline-type (map->obj (merge common props))]))<commit_msg>:bug: Fixes problem with outline and zoom<commit_after>;; 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/.
;;
;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0.
;;
;; Copyright (c) 2020 UXBOX Labs SL

(ns uxbox.main.ui.workspace.shapes.outline
  (:require
   [rumext.alpha :as mf]
   [uxbox.common.geom.shapes :as gsh]
   [uxbox.util.object :as obj]
   [rumext.util :refer [map->obj]]
   [uxbox.main.ui.shapes.path :as path]
   [uxbox.main.refs :as refs]))


(mf/defc outline
  {::mf/wrap-props false}
  [props]
  (let [zoom (mf/deref refs/selected-zoom)
        shape (unchecked-get props "shape")
        transform (gsh/transform-matrix shape)
        {:keys [id x y width height]} shape

        outline-type (case (:type shape)
                       :circle "ellipse"
                       (:curve :path) "path"
                       "rect")

        common {:fill "transparent"
                :stroke "#31EFB8"
                :strokeWidth (/ 1 zoom)
                :pointerEvents "none"
                :transform transform}

        props (case (:type shape)
                :circle
                {:cx (+ x (/ width 2))
                 :cy (+ y (/ height 2))
                 :rx (/ width 2)
                 :ry (/ height 2)}
                
                (:curve :path)
                {:d (path/render-path shape)}
                
                {:x x
                 :y y
                 :width width
                 :height height})]

    [:> outline-type (map->obj (merge common props))]))
{'fraction_non_alphanumeric': 0.12373887240356084, 'fraction_numerical': 0.010682492581602374, 'mean_word_length': 1.5811638591117918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4936527', 'n_tokens_mistral': 1068, 'n_tokens_neox': 973, 'n_words': 322}