0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

♻️ Fixes after review

This commit is contained in:
alonso.torres 2020-11-24 09:44:12 +01:00
parent b37ee0fcac
commit 25fe4f1269
4 changed files with 30 additions and 84 deletions

View file

@ -44,18 +44,26 @@
(move shape (gpt/point dx dy))))
;; --- Resize (Dimensions)
;;; TODO: CHANGE TO USE THE MODIFIERS
;; Fixme: Improve using modifiers instead of calculating the selrect/points
(defn resize
[shape width height]
(us/assert map? shape)
(us/assert number? width)
(us/assert number? height)
(-> shape
(assoc :width width :height height)
(update :selrect (fn [selrect]
(assoc selrect
:x2 (+ (:x1 selrect) width)
:y2 (+ (:y1 selrect) height))))))
(let [selrect (-> (:selrect shape)
(assoc :width width)
(assoc :height height)
(assoc :x2 (+ (-> shape :selrect :x1) width))
(assoc :y2 (+ (-> shape :selrect :y1) height)))
center (gco/center-selrect selrect)
points (-> selrect gpr/rect->points (gtr/transform-points center (:transform shape)))]
(-> shape
(assoc :width width)
(assoc :height height)
(assoc :selrect selrect)
(assoc :points points))))
(defn resize-rect
[shape attr value]

View file

@ -1,56 +1,3 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="500"
viewBox="0 0 500.00001 500.00001"
width="500"
version="1.1"
id="svg4"
sodipodi:docname="pen.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3840"
inkscape:window-height="2086"
id="namedview6"
showgrid="false"
inkscape:zoom="1.3350176"
inkscape:cx="551.31385"
inkscape:cy="371.25461"
inkscape:window-x="3840"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
style="clip-rule:evenodd;fill:#000000;fill-rule:evenodd;stroke:none;stroke-width:7.82213879;stroke-miterlimit:4;stroke-dasharray:none"
d="M 1.75e-5,-0.0344246 1.8524271,6.6323446 C 21.707431,76.98556 39.775647,154.86535 49.997926,218.44692 c -0.005,-0.0421 -0.01033,-0.0839 -0.01528,-0.12604 l 0.02101,0.1566 c -0.0017,-0.0103 -0.0041,-0.0203 -0.0058,-0.0305 6.542466,55.39121 29.322431,104.35363 62.177964,137.22926 32.90376,36.13782 79.12263,55.8626 134.67028,55.8626 10.16195,0 19.79295,-0.54966 28.99882,-1.54495 l 90.04053,90.04053 134.11453,-137.46988 -88.9329,-88.93482 c 0.46511,-8.60602 0.50799,-17.51305 0.50799,-26.81795 0,-55.50516 -19.75987,-101.81434 -59.11101,-134.70654 C 319.51383,75.993429 270.47749,56.500337 215.36282,49.978756 137.69366,41.205798 73.142832,20.282665 1.75e-5,-0.0344246 Z M 99.23386,67.935688 c 37.99513,8.774093 76.30079,16.144787 114.86856,21.925279 l 0.0325,0.0039 0.0305,0.0059 c 47.63845,6.351798 87.01754,22.988383 114.40641,49.203453 27.3689,26.19596 42.99135,61.9504 43.01413,107.64035 l -3.34007,43.4018 4.48971,4.4897 22.51347,22.51348 48.69546,48.69549 -78.09341,78.09343 -48.69739,-48.6974 -0.0134,-0.0134 -25.26535,-25.26535 -1.67863,1.67862 -0.0669,-0.0573 h -43.28338 c -45.73783,0 -81.52124,-15.63099 -107.73583,-43.01986 C 112.89574,301.14472 96.25867,261.76757 89.906869,214.12908 84.324003,166.70136 76.438965,129.4996 70.223571,101.44904 L 181.85519,213.08066 c -12.12343,33.53406 12.70563,69.75968 48.90364,69.80533 h 0.004 0.002 c 28.75911,0 52.15587,-23.39869 52.15587,-52.15777 0,-28.75909 -23.39676,-52.15587 -52.15587,-52.15587 h -0.002 c -6.05426,0.003 -12.03463,1.12108 -17.71439,3.17774 z"
id="path821"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccsccccscccccccscccccccccccsccccccsssccc" />
<svg width="500" height="500" version="1.1" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
<path d="m1.75e-5 -0.034425 1.8524 6.6668c19.855 70.353 37.923 148.23 48.145 211.81-5e-3 -0.0421-0.01033-0.0839-0.01528-0.12604l0.02101 0.1566c-0.0017-0.0103-0.0041-0.0203-0.0058-0.0305 6.5425 55.391 29.322 104.35 62.178 137.23 32.904 36.138 79.123 55.863 134.67 55.863 10.162 0 19.793-0.54966 28.999-1.545l90.041 90.041 134.11-137.47-88.933-88.935c0.46511-8.606 0.50799-17.513 0.50799-26.818 0-55.505-19.76-101.81-59.111-134.71-32.95-36.112-81.987-55.605-137.1-62.126-77.669-8.773-142.22-29.696-215.36-50.013zm99.234 67.97c37.995 8.7741 76.301 16.145 114.87 21.925l0.0325 0.0039 0.0305 0.0059c47.638 6.3518 87.018 22.988 114.41 49.203 27.369 26.196 42.991 61.95 43.014 107.64l-3.3401 43.402 75.699 75.699-78.093 78.093-73.976-73.976-1.6786 1.6786-0.0669-0.0573h-43.283c-45.738 0-81.521-15.631-107.74-43.02-26.214-27.389-42.852-66.766-49.203-114.4-5.5829-47.428-13.468-84.629-19.683-112.68l111.63 111.63c-12.123 33.534 12.706 69.76 48.904 69.805h6e-3c28.759 0 52.156-23.399 52.156-52.158 0-28.759-23.397-52.156-52.156-52.156h-2e-3c-6.0543 3e-3 -12.035 1.1211-17.714 3.1777z" clip-rule="evenodd" fill-rule="evenodd"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -1662,7 +1662,7 @@
"e" #(st/emit! (dwd/select-for-drawing :circle))
"t" #(st/emit! dwtxt/start-edit-if-selected
(dwd/select-for-drawing :text))
"w" #(st/emit! (dwd/select-for-drawing :path))
"p" #(st/emit! (dwd/select-for-drawing :path))
"ctrl+c" #(st/emit! copy-selected)
"ctrl+v" #(st/emit! paste)
"ctrl+x" #(st/emit! copy-selected delete-selected)

View file

@ -101,12 +101,7 @@
;; EVENTS
(defn init-path [id]
(ptk/reify ::init-path
ptk/UpdateEvent
(update [_ state]
(-> state
#_(assoc-in [:workspace-drawing :object :initialized?] true)
#_(assoc-in [:workspace-local :edit-path :last-point] nil)))))
(ptk/reify ::init-path))
(defn finish-path [id]
(ptk/reify ::finish-path
@ -347,13 +342,11 @@
(make-drag-stream stream %)
(make-dbl-click-stream stream %))))]
(->> (rx/concat
(rx/of (init-path id))
(rx/merge mousemove-events
mousedown-events)
(rx/of (finish-path id))))))))
(rx/concat
(rx/of (init-path id))
(rx/merge mousemove-events
mousedown-events)
(rx/of (finish-path id)))))))
(defn stop-path-edit []
(ptk/reify ::stop-path-edit
@ -417,13 +410,13 @@
(watch [_ state stream]
(let [id (get-in state [:workspace-local :edition])
page-id (:current-page-id state)
old-content (get-in state [:workspace-data :pages-index page-id :objects id :content])
old-selrect (get-in state [:workspace-data :pages-index page-id :objects id :selrect])
old-points (get-in state [:workspace-data :pages-index page-id :objects id :points])
content-modifiers (get-in state [:workspace-local :edit-path id :content-modifiers])
shape (get-in state [:workspace-data :pages-index page-id :objects id])
{old-content :content old-selrect :selrect old-points :points} shape
content-modifiers (get-in state [:workspace-local :edit-path id :content-modifiers] {})
new-content (ugp/apply-content-modifiers old-content content-modifiers)
new-selrect (gsh/content->selrect new-content)
new-points (gsh/rect->points new-selrect)
rch [{:type :mod-obj
:id id
:page-id page-id
@ -456,9 +449,8 @@
old-content (get-in state [:workspace-local :edit-path id :old-content])
old-selrect (gsh/content->selrect old-content)
old-points (gsh/rect->points old-content)
new-content (get-in state [:workspace-data :pages-index page-id :objects id :content])
new-selrect (get-in state [:workspace-data :pages-index page-id :objects id :selrect])
new-points (get-in state [:workspace-data :pages-index page-id :objects id :points])
shape (get-in state [:workspace-data :pages-index page-id :objects id])
{new-content :content new-selrect :selrect new-points :points} shape
rch [{:type :mod-obj
:id id
@ -491,7 +483,6 @@
content (get-in state (get-path state :content))
old-content (get-in state [:workspace-local :edit-path id :old-content])
mode (get-in state [:workspace-local :edit-path id :edit-mode])]
(cond
(not= content old-content) (rx/of (save-path-content)