|
34 | 34 | ;; But they're much more interesting if we use
|
35 | 35 | ;; [Clojure2D](https://github.com/Clojure2D/clojure2d) canvas to draw
|
36 | 36 | ;; a path made from points to show the complete curve:
|
37 |
| -(c2d/with-canvas [canvas (c2d/canvas 800 800 :highest)] |
38 |
| - (-> canvas |
39 |
| - (c2d/set-background 255 255 255) |
40 |
| - (c2d/set-color 66 66 66) |
41 |
| - (c2d/set-stroke 4) |
42 |
| - (c2d/path hilbert-points) |
43 |
| - c2d/to-image)) |
| 37 | +(c2d/with-canvas-> (c2d/canvas 800 800 :highest) |
| 38 | + (c2d/set-background 255 255 255) |
| 39 | + (c2d/set-color 66 66 66) |
| 40 | + (c2d/set-stroke 4) |
| 41 | + (c2d/path hilbert-points) |
| 42 | + c2d/to-image) |
44 | 43 |
|
45 | 44 | ;; The trick to getting the effect we want is to apply a conformal
|
46 | 45 | ;; mapping to the original Hilbert Curve to convert it into an 👁 shape
|
|
52 | 51 | ;; author's [Fastmath](https://github.com/generateme/fastmath)
|
53 | 52 | ;; library. 🎉
|
54 | 53 |
|
55 |
| -(c2d/with-canvas [canvas (c2d/canvas 1000 600 :highest)] |
56 |
| - (-> canvas |
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, ⬯ → ⬭ |
60 |
| - ;; colour and stroke width |
61 |
| - (c2d/set-color 147.0 189.0 154.0) |
62 |
| - (c2d/set-stroke 4) |
63 |
| - ;; ellipses to fill in the center of the "eye" |
64 |
| - (c2d/ellipse 0 0 22 22) |
65 |
| - (c2d/ellipse 0 -10 20 20) |
66 |
| - (c2d/ellipse 0 10 20 20) |
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)) |
| 54 | +(c2d/with-canvas-> (c2d/canvas 1000 600 :highest) |
| 55 | + (c2d/set-background 33.0 5.0 24.0) ; RGB deep purple |
| 56 | + (c2d/translate 500 300) ; origin to center |
| 57 | + (c2d/rotate (/ Math/PI 2)) ; rotate the canvas, ⬯ → ⬭ |
| 58 | + ;; colour and stroke width |
| 59 | + (c2d/set-color 147.0 189.0 154.0) |
| 60 | + (c2d/set-stroke 4) |
| 61 | + ;; ellipses to fill in the center of the "eye" |
| 62 | + (c2d/ellipse 0 0 22 22) |
| 63 | + (c2d/ellipse 0 -10 20 20) |
| 64 | + (c2d/ellipse 0 10 20 20) |
| 65 | + ;; draw a path using the complex square of our hilbert curve points |
| 66 | + (c2d/path (map #(-> (v/sub % (v/vec2 400 400)) ; -[½w ½h] from vectors to center the curve |
| 67 | + complex/sq ; square each vector as a complex number |
| 68 | + (v/mult 0.0015)) ; scale those squared vectors down |
| 69 | + hilbert-points)) |
| 70 | + c2d/to-image) |
73 | 71 |
|
74 | 72 | ;; What I find so special and enchanting about the $$w = z^{2}$$
|
75 | 73 | ;; mapping that we're using here is that it maintains the angle of
|
|
0 commit comments