Switched from dali to hiccup for rendering SVG, because performance
This commit is contained in:
		
							parent
							
								
									384be4c43c
								
							
						
					
					
						commit
						69fd075acc
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							|  | @ -6,6 +6,8 @@ pom.xml | ||||||
| pom.xml.asc | pom.xml.asc | ||||||
| *.jar | *.jar | ||||||
| *.class | *.class | ||||||
|  | *.stl | ||||||
|  | *.svg | ||||||
| /.lein-* | /.lein-* | ||||||
| /.nrepl-port | /.nrepl-port | ||||||
| .hgignore | .hgignore | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ | ||||||
|                  [org.clojure/math.numeric-tower "0.0.4"] |                  [org.clojure/math.numeric-tower "0.0.4"] | ||||||
|                  [com.taoensso/timbre "4.10.0"] |                  [com.taoensso/timbre "4.10.0"] | ||||||
|                  [dali "0.7.4"] |                  [dali "0.7.4"] | ||||||
|  |                  [hiccup "1.0.5"] | ||||||
|                  [me.raynes/fs "1.4.6"] |                  [me.raynes/fs "1.4.6"] | ||||||
|                  [smee/binary "0.5.5"]] |                  [smee/binary "0.5.5"]] | ||||||
|   :description "A Clojure library designed to assist in computing walkmaps for games." |   :description "A Clojure library designed to assist in computing walkmaps for games." | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ | ||||||
|   (STL) files. Not a stable API yet!" |   (STL) files. Not a stable API yet!" | ||||||
|   (:require [clojure.java.io :as io :refer [file output-stream input-stream]] |   (:require [clojure.java.io :as io :refer [file output-stream input-stream]] | ||||||
|             [clojure.string :as s] |             [clojure.string :as s] | ||||||
|             [dali.io :as svg] |             [hiccup.core :refer [html]] | ||||||
|             [me.raynes.fs :as fs] |             [me.raynes.fs :as fs] | ||||||
|             [org.clojars.smee.binary.core :as b] |             [org.clojars.smee.binary.core :as b] | ||||||
|             [taoensso.timbre :as l :refer [info error spy]]) |             [taoensso.timbre :as l :refer [info error spy]]) | ||||||
|  | @ -102,10 +102,8 @@ | ||||||
| 
 | 
 | ||||||
| (defn- facet-to-svg-poly | (defn- facet-to-svg-poly | ||||||
|   [facet] |   [facet] | ||||||
|   (vec |   [:polygon | ||||||
|     (cons |    {:points (s/join " " (map #(str (:x %) "," (:y %)) (:vertices facet)))}]) | ||||||
|       :polygon |  | ||||||
|       (map #(vec (list (:x %) (:y %))) (:vertices facet))))) |  | ||||||
| 
 | 
 | ||||||
| (defn stl-to-svg | (defn stl-to-svg | ||||||
|   "Convert this in-memory `stl` structure, as read by `decode-binary-stl`, into |   "Convert this in-memory `stl` structure, as read by `decode-binary-stl`, into | ||||||
|  | @ -131,8 +129,10 @@ | ||||||
|                (map |                (map | ||||||
|                  #(reduce max (map :y (:vertices %))) |                  #(reduce max (map :y (:vertices %))) | ||||||
|                  (:facets stl)))] |                  (:facets stl)))] | ||||||
|     [:dali/page |     [:svg | ||||||
|      {:width (- maxx minx) |      {:xmlns "http://www.w3.org/2000/svg" | ||||||
|  |       :version "1.2" | ||||||
|  |       :width (- maxx minx) | ||||||
|       :height (- maxy miny) |       :height (- maxy miny) | ||||||
|       :viewBox (s/join " " (map str [minx miny maxx maxy]))} |       :viewBox (s/join " " (map str [minx miny maxx maxy]))} | ||||||
|      (vec |      (vec | ||||||
|  | @ -150,7 +150,8 @@ | ||||||
|    (stl-to-svg (decode-binary-stl in-filename))) |    (stl-to-svg (decode-binary-stl in-filename))) | ||||||
|   ([in-filename out-filename] |   ([in-filename out-filename] | ||||||
|    (let [s (binary-stl-file-to-svg in-filename)] |    (let [s (binary-stl-file-to-svg in-filename)] | ||||||
|      (svg/render-svg s out-filename) |      ;; (svg/render-svg s out-filename) | ||||||
|  |      (spit out-filename (html s)) | ||||||
|      s))) |      s))) | ||||||
| 
 | 
 | ||||||
| ;; (def stl (decode-binary-stl "resources/small_hill.stl")) | ;; (def stl (decode-binary-stl "resources/small_hill.stl")) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue