Skip to content

Commit

Permalink
Add Eye of Sine Plot
Browse files Browse the repository at this point in the history
  • Loading branch information
rollacaster committed Dec 20, 2020
1 parent 50c58bc commit e00b75a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
5 changes: 4 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
:exclusions [com.lowagie/itext]}
binaryage/oops {:mvn/version "0.7.0"}
rollacaster/clj-axidraw {:git/url "https://github.com/rollacaster/clj-axidraw"
:sha "e31824cf8def9dd01d9b3aa5a5f2e5eddf70f900"}}
:sha "e31824cf8def9dd01d9b3aa5a5f2e5eddf70f900"}
thi.ng/geom {:mvn/version "1.0.0-RC4"}
thi.ng/math {:mvn/version "0.3.0"}
thi.ng/color {:mvn/version "1.4.0"}}
:paths ["src" "target" "resources"]}
37 changes: 37 additions & 0 deletions src/sketches/plotting/eye_of_sine.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(ns sketches.plotting.eye-of-sine
(:require [thi.ng.geom.svg.adapter :as adapt]
[thi.ng.geom.svg.core :as svg :refer [ellipse]]))
(def scene
(svg/svg
{:width 300 :height 300}
(svg/group
{}
(let [rings 50]
(map
(fn [i]
(let [progress-in-percent (/ i rings)
cur-pi (* progress-in-percent Math/PI)
min-width 0
max-additional-width 80]
(ellipse [150 (+ 20 (* 5 i))] (+ min-width (* max-additional-width (Math/sin cur-pi))) 10
{:fill "none" :stroke "black"})))
(range rings))))
(svg/group
{:transform "rotate(90) translate(0 -300)"}
(let [rings 50]
(map
(fn [i]
(let [progress-in-percent (/ i rings)
cur-pi (* progress-in-percent Math/PI)
min-width 0
max-additional-width 80]
(ellipse [150 (+ 20 (* 5 i))] (+ min-width (* max-additional-width (Math/sin cur-pi))) 10
{:fill "none" :stroke "black"})))
(range rings))))))

(comment
(->> scene
adapt/all-as-svg
svg/serialize
(spit "temp.svg")))

0 comments on commit e00b75a

Please sign in to comment.