Skip to content

Commit 27796d4

Browse files
committed
Integrate genmeblog's PR, tidy the description some more.
1 parent ee95624 commit 27796d4

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

notebooks/logo.clj

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,42 @@
3939
(c2d/set-background 255 255 255)
4040
(c2d/set-color 66 66 66)
4141
(c2d/set-stroke 4)
42-
(c2d/path hilbert-points))
43-
;; just the underlying BufferedImage, please
44-
(c2d/to-image canvas))
42+
(c2d/path hilbert-points)
43+
c2d/to-image))
4544

4645
;; The trick to getting the effect we want is to apply a conformal
4746
;; mapping to the original Hilbert Curve to convert it into an 👁 shape
4847
;; in celebration of Clerk's viewers. We can do this by treating the
49-
;; original point coordinates as complex numbers,
50-
;; squaring them, then taking the real and imaginary portions of each
51-
;; of those complex numbers as the _x_ and _y_ coordinates of a new
52-
;; set of points. This is made especially easy because Clojure2D
53-
;; happens to include the author's
54-
;; [Fastmath](https://github.com/generateme/fastmath) library.
48+
;; original point coordinates as complex numbers, squaring them, then
49+
;; taking the real and imaginary portions of each of those complex
50+
;; numbers as the _x_ and _y_ coordinates of a new set of points. This
51+
;; is made especially easy because Clojure2D happens to include the
52+
;; author's [Fastmath](https://github.com/generateme/fastmath)
53+
;; library. 🎉
5554

5655
(c2d/with-canvas [canvas (c2d/canvas 1000 600 :highest)]
5756
(-> canvas
58-
(c2d/set-background 33.0 5.0 24.0)
59-
(c2d/translate 500 300) ; origin to center
60-
(c2d/rotate (/ Math/PI 2)) ; rotate canvas around origin
57+
(c2d/set-background 33.0 5.0 24.0) ; RGB deep purple
58+
(c2d/translate 500 300) ; origin to center
59+
(c2d/rotate (/ Math/PI 2)) ; rotate the canvas, ⬯ → ⬭
6160
;; colour and stroke width
6261
(c2d/set-color 147.0 189.0 154.0)
6362
(c2d/set-stroke 4)
6463
;; ellipses to fill in the center of the "eye"
6564
(c2d/ellipse 0 0 22 22)
6665
(c2d/ellipse 0 -10 20 20)
6766
(c2d/ellipse 0 10 20 20)
68-
;; create a path from complex square of hilbert curve points
69-
(c2d/path (map (fn [p]
70-
;; center the curve
71-
(-> (v/sub p (v/vec2 400 400))
72-
;; square it (as complex numbers!)
73-
(complex/sq)
74-
;; scale the squared values down
75-
(v/mult 0.0015))) hilbert-points)))
76-
(c2d/to-image canvas))
67+
;; draw a path using the complex square of our hilbert curve points
68+
(c2d/path (map #(-> (v/sub % (v/vec2 400 400)) ; -[½w ½h] from vectors to center the curve
69+
complex/sq ; square each vector as a complex number
70+
(v/mult 0.0015)) ; scale those squared vectors down
71+
hilbert-points))
72+
c2d/to-image))
7773

7874
;; What I find so special and enchanting about the $$w = z^{2}$$
7975
;; mapping that we're using here is that it maintains the angle of
8076
;; intersection everywhere but $$z = 0$$ (the origin). 📐
8177

82-
;; It's called a conformal map by mathematicians. 😍
78+
;; This is called a _conformal map_ by mathematicians. 😍
8379

8480
#_(clerk/show! "notebooks/logo.clj")

0 commit comments

Comments
 (0)