Skip to content

Commit

Permalink
feat: stroke style for circles
Browse files Browse the repository at this point in the history
  • Loading branch information
erdos committed Nov 10, 2019
1 parent 921ac18 commit 1afdb20
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/erdos/lenart/canvas.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

(def defs
[:defs
[:pattern {:id "diag" :patternUnits "userSpaceOnUse" :width 4 :heigt 4}
#_[:pattern {:id "diag" :patternUnits "userSpaceOnUse" :width 4 :heigt 4}
[:path {:d "M-1,1 l2,-2
M0,4 l4,-4
M3,5 l2,-2"}]
Expand All @@ -46,6 +46,7 @@
(binding [*style* (assoc *style*
:fill (c/color->backface (:color x "blue"))
:stroke (c/color->backface (:color x "black"))
:stroke-style (:stroke-style x :normal)
:stroke-width (:size x 2))]
(-> (case (:type x)
:segment (create-segment-backface (pt (:from x)) (pt (:to x)))
Expand All @@ -65,6 +66,7 @@
(binding [*style* (assoc *style*
:fill (:color x "blue")
:stroke (:color x "black")
:stroke-style (:stroke-style x :normal)
:stroke-width (:size x 2))]
(-> (case (:type x)
:segment (create-segment (pt (:from x)) (pt (:to x)))
Expand Down
6 changes: 6 additions & 0 deletions src/erdos/lenart/common.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
;(format "M%.4f,%.4f A%.4f,%.4f %.4f %d,%d %.4f,%.4f" x0 y0 w h ang f0 f1 x1 y1)
:fill "none";(:fill *style* "none"),
:stroke (:stroke *style* "black")
:stroke-dasharray (case (:stroke-style *style* :normal)
:dotted (str (:stroke-width *style* 2))
:dashed (str (* 4 (:stroke-width *style* 2))
" "
(* 2 (:stroke-width *style* 2)))
:normal nil)
:stroke-width (:stroke-width *style* 1)}])

(defn line [x0 y0 x1 y1]
Expand Down
6 changes: 6 additions & 0 deletions src/erdos/lenart/lang.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
(-> ?xs parse-style-item (assoc :color ?c)) ;; color
["size" ?s & ?xs]
(-> ?xs parse-style-item (assoc :size ?s)) ;; stroke width

["stroke" "dashed" & ?xs]
(-> ?xs parse-style-item (assoc :stroke-style :dashed))

["stroke" "dotted" & ?xs]
(-> ?xs parse-style-item (assoc :stroke-style :dotted))
))

(defn- parse-style [s]
Expand Down

0 comments on commit 1afdb20

Please sign in to comment.