Commit unstaged changes
This commit is contained in:
parent
c340684b33
commit
15e5cfc8e3
6 changed files with 59 additions and 25 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
report.html
|
||||
node_modules
|
||||
.shadow-cljs
|
||||
resources/public/js
|
||||
|
|
|
|||
20
README.md
20
README.md
|
|
@ -1,9 +1,27 @@
|
|||
# Rect-Packing
|
||||
|
||||
This folder contains a small project that aims to help in finding a good way to position individual cuttings on a frame. It is currently a work in progress.
|
||||
|
||||
## Dev environment
|
||||
|
||||
This project is built using `shadow-cljs`:
|
||||
|
||||
``` bash
|
||||
npx shadow-cljs watch :app
|
||||
```
|
||||
|
||||
Use `cider-connect-cljs` to connect to the REPL in emacs after opening http://localhost:8080 in your browser. :)
|
||||
Use `cider-connect-cljs` to connect to the REPL in emacs after opening http://localhost:8080 in your browser. Alternatively you can just call `cider-jack-in-cljs` and select the app build. :)
|
||||
|
||||
### Production Build
|
||||
|
||||
``` bash
|
||||
npx shadow-cljs release :app
|
||||
```
|
||||
|
||||
A [build report](https://shadow-cljs.github.io/docs/UsersGuide.html#build-report) will automatically be created and written to `resources/public/js/report.html`.
|
||||
|
||||
## Tentative Roadmap
|
||||
|
||||
- [ ] Warn when rects don't fit the given frame(s)
|
||||
- [ ] Show coverage quote
|
||||
- [ ] Allow multiple frames
|
||||
|
|
|
|||
16
deps.edn
16
deps.edn
|
|
@ -1,14 +1,12 @@
|
|||
{:paths ["src" "resources"]
|
||||
:deps {org.clojure/clojure {:mvn/version "1.10.0"}
|
||||
thi.ng/geom {:mvn/version "1.0.0-RC3"
|
||||
thi.ng/geom {:mvn/version "1.0.0-RC4"
|
||||
:exclusions [org.jogamp.jogl/jogl-all
|
||||
org.jogamp.gluegen/gluegen-rt]}}
|
||||
|
||||
:aliases
|
||||
;; clojurescript build tool and dependencies (see also shadow-cljs.edn)
|
||||
{:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.109"}
|
||||
org.jogamp.gluegen/gluegen-rt]}
|
||||
appliedscience/js-interop {:mvn/version "0.2.5"}
|
||||
reagent/reagent {:mvn/version "1.1.0"}
|
||||
fipp/fipp {:mvn/version "0.6.25"}
|
||||
#_#_ refactor-nrepl/refactor-nrepl {:mvn/version "3.1.0"}
|
||||
#_#_ cider/cider-nrepl {:mvn/version "0.27.2"}}}}}
|
||||
fipp/fipp {:mvn/version "0.6.25"}}
|
||||
|
||||
:aliases
|
||||
;; clojurescript build tool (see also shadow-cljs.edn)
|
||||
{:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.16.10"}}}}}
|
||||
|
|
|
|||
14
dev/user.clj
Normal file
14
dev/user.clj
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(ns user
|
||||
(:require [shadow.cljs.devtools.api :as shadow]
|
||||
[shadow.cljs.devtools.server :as server]))
|
||||
|
||||
;; copied from https://docs.cider.mx/cider/cljs/shadow-cljs.html
|
||||
|
||||
(defn cljs-repl
|
||||
"Connects to a given build-id. Defaults to `:app`."
|
||||
([]
|
||||
(cljs-repl :app))
|
||||
([build-id]
|
||||
(server/start!)
|
||||
(shadow/watch build-id)
|
||||
(shadow/nrepl-select build-id)))
|
||||
|
|
@ -7,4 +7,4 @@
|
|||
{:app {:target :browser
|
||||
:output-dir "resources/public/js"
|
||||
:asset-path "/js"
|
||||
:modules {:main {:entries [heyarne.rect-packing.core]}}}} }
|
||||
:modules {:main {:entries [heyarne.rect-packing.core]}}}}}
|
||||
|
|
|
|||
|
|
@ -100,8 +100,11 @@
|
|||
(defn remove-rects-of-size! [size]
|
||||
(swap! state update :rects dissoc size))
|
||||
|
||||
(defn inventory [rects]
|
||||
(defn inventory [frame rects]
|
||||
[:<>
|
||||
[:h2 "Frames"]
|
||||
[:pre (prn-str frame)]
|
||||
[:h2 "Rectangles"]
|
||||
[order]
|
||||
(when (seq rects)
|
||||
[:<>
|
||||
|
|
@ -122,6 +125,8 @@
|
|||
:title (str "Remove " n " items")} "❌"]])]])])
|
||||
|
||||
(defn visualization [frame packed-rects]
|
||||
[:<>
|
||||
[:h1 "Visualization"]
|
||||
[:svg.visualization {:viewBox "-0.5 -0.5 501 501" :xmlns "http://www.w3.org/2000/svg"}
|
||||
[:rect {:width (geom/width frame)
|
||||
:height (geom/height frame)}]
|
||||
|
|
@ -131,16 +136,14 @@
|
|||
h (geom/height rect)]]
|
||||
^{:key idx} [:<>
|
||||
[:rect {:width w :height h :x x :y y}]
|
||||
[:text {:x x :y y :dx 4 :dy 14} (str w "x" h)]])])
|
||||
[:text {:x x :y y :dx 4 :dy 14} (str w "x" h)]])]])
|
||||
|
||||
(defn main []
|
||||
(let [{:keys [frame rects]} @state
|
||||
packed @packed-rects]
|
||||
[:main
|
||||
[:h1 "Visualization"]
|
||||
[visualization frame packed]
|
||||
[:h2 "Rectangles"]
|
||||
[inventory rects]]))
|
||||
[inventory frame rects]]))
|
||||
|
||||
(defn ^:dev/after-load init []
|
||||
(println "Initializing…")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue