Skip to content

Instantly share code, notes, and snippets.

@chimanaco
Created July 1, 2020 00:20
Show Gist options
  • Save chimanaco/fe01acae4e5e18a22d5baf6059cdaa45 to your computer and use it in GitHub Desktop.
Save chimanaco/fe01acae4e5e18a22d5baf6059cdaa45 to your computer and use it in GitHub Desktop.
;; Example: Replicator
(defn path/replicator
[xform n path]
(->> (reduce #(conj % (mat2d/* (last %) xform))
[(mat2d/ident)]
(range (dec n)))
(map #(path/transform % path))))
:start-sketch
(defvar center [-2 1.8125])
(defvar cx -122)
(defvar cy -125)
(defvar tx 0)
(defvar ty 110.1875)
(defvar repetition 100)
(defvar radius 28.017851452243796)
(defvar rScale [0.95 0.95])
(defvar rDeg 702.7851474423392)
(background "Wheat")
(style (fill "Tomato")
(style (stroke "#CECCFF")
(path/replicator
(mat2d/* (translate [tx (* -1 ty)])
(rotate (deg rDeg))
(scale rScale)
)
repetition
(circle center radius)
)
(path/replicator
(mat2d/* (translate [(* -1 tx) (* -1 ty)])
(rotate (deg (* -1 rDeg)))
(scale rScale)
)
repetition
(circle center radius)
)
(path/replicator
(mat2d/* (translate [tx ty])
(rotate (deg (* -1 rDeg)))
(scale rScale)
)
repetition
(circle center radius)
)
(path/replicator
(mat2d/* (translate [ (* -1 tx) ty ])
(rotate (deg rDeg))
(scale rScale)
)
repetition
(circle center radius)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment