-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move around working, memory for around 110 nodes is still too high 20…
…0mb, fixed update node in rama
- Loading branch information
Showing
8 changed files
with
386 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,57 @@ | ||
(ns app.client.shapes.line | ||
(:require [hyperfiddle.electric-svg :as svg] | ||
[hyperfiddle.electric :as e] | ||
[hyperfiddle.electric-dom2 :as dom])) | ||
[app.client.flow-calc :as fc] | ||
[hyperfiddle.electric-dom2 :as dom] | ||
[app.client.utils :refer [ ui-mode edges nodes | ||
is-dragging? zoom-level last-position subscribe | ||
viewbox context-menu? reset-global-vals]])) | ||
(defn attributes [x y height width a b] | ||
(let [xmin x | ||
ymin y | ||
xmax (+ x width) | ||
ymax (+ y height) | ||
rx (atom nil) | ||
ry (atom nil)] | ||
(println "xmin" xmin "xmax" xmax "ymin" ymin "ymax" ymax "a " a "b" b) | ||
(cond | ||
(<= a xmin) (reset! rx xmin) | ||
(>= a xmax) (reset! rx xmax) | ||
:else (reset! rx a)) | ||
(cond | ||
(<= b ymin) (reset! ry ymin) | ||
(>= b ymax) (reset! ry ymax) | ||
:else (reset! ry b)) | ||
[@rx @ry])) | ||
|
||
(comment | ||
(attributes 0 0 100 100 -51 51) | ||
(attributes 0 0 100 100 51 51) | ||
(attributes 0 0 100 100 -51 -51) | ||
(attributes 0 0 100 100 51 -51) | ||
(attributes 0 0 100 100 51 -21)) | ||
|
||
(e/defn line [[k {:keys [id color to from]}]] | ||
(println "--->" k id color to from) | ||
(println "--"[to :y]) | ||
(e/client | ||
(let [tw (subscribe. [ to :width]) | ||
th (subscribe. [ to :height]) | ||
fw (subscribe. [ from :width]) | ||
fh (subscribe. [ from :height]) | ||
tx (subscribe. [ to :x]) | ||
ty (subscribe. [ to :y]) | ||
fx (subscribe. [ from :x]) | ||
fy (subscribe. [ from :y])] | ||
(let [tw (int (subscribe. [ to :type-specific-data :width])) | ||
th (int (subscribe. [ to :type-specific-data :height])) | ||
tx (int (subscribe. [to :x])) | ||
ty (int (subscribe. [to :y])) | ||
fx (int (subscribe. [from :x])) | ||
fy (int (subscribe. [from :y])) | ||
[xx yy] (attributes tx ty th tw fx fy)] | ||
(svg/line | ||
(dom/props {:style {:z-index -1} | ||
:id id | ||
:x1 (if tw | ||
(+ tx) (/ tw 2) | ||
tx) | ||
:y1 (if th | ||
(+ ty (/ th 2)) | ||
ty) | ||
:x2 (if fw | ||
(+ fx (/ fw 2)) | ||
fx) | ||
:y2 (if fh | ||
(+ fy (/ fh 2)) | ||
fy) | ||
:x1 xx #_(if tw | ||
(+ tx) (/ tw 2) | ||
tx) | ||
:y1 yy #_(if th | ||
(+ ty (/ th 2)) | ||
ty) | ||
:x2 fx | ||
:y2 fy | ||
:stroke color | ||
:stroke-width 4}))))) |
Oops, something went wrong.