|
1 |
| -(ns ex65-spinning-flower-mandala |
| 1 | +(ns ex66-spinning-flower-mandala |
2 | 2 | (:require [clojure2d.core :as c2d]
|
3 | 3 | [clojure2d.pixels :as p]
|
4 | 4 | [clojure2d.extra.overlays :as o]
|
|
18 | 18 | frame-rate (m// (m/* frameno 1000000000.0) elapsed-time)
|
19 | 19 | o-r (m/* 2 (m/+ outer-radius (m/* 5 (m/sin (m// frameno m/TWO_PI 5)))))
|
20 | 20 | rot-angle (m/mod (m// frameno m/TWO_PI 60) m/TWO_PI)]
|
21 |
| - ;;ඛණ්ඩාංක පද්ධතිය සෙටප් කිරීම |
| 21 | + ;;Translate and setup coords |
22 | 22 | (-> canvas
|
23 | 23 | (c2d/scale 2)
|
24 | 24 | (c2d/translate 150 150)
|
25 | 25 | (c2d/rotate rot-angle)
|
26 | 26 | (c2d/flip-y))
|
27 |
| - ;;කහ පැහැ පල්ස් වෙන රැස් මාලාව |
| 27 | + ;;Back halo |
28 | 28 | (-> canvas
|
29 | 29 | (c2d/set-color 116 88 20 120)
|
30 | 30 | (c2d/ellipse 0 0 o-r o-r)
|
|
34 | 34 | (c2d/ellipse 0 0 (m/- o-r 8) (m/- o-r 8))
|
35 | 35 | (c2d/set-color 232 177 40 120)
|
36 | 36 | (c2d/ellipse 0 0 (m/- o-r 8) (m/- o-r 8)))
|
37 |
| - ;;රැස් බොඳ |
| 37 | + ;;Blur halo |
38 | 38 | (p/set-canvas-pixels! canvas
|
39 | 39 | (->> canvas
|
40 | 40 | p/to-pixels
|
41 | 41 | (p/filter-channels p/gaussian-blur-5)))
|
42 |
| - ;;මැද ඉද්ද මල |
| 42 | + ;;Idda flower at the center https://en.wikipedia.org/wiki/Wrightia_antidysenterica |
43 | 43 | (dotimes [_ 5]
|
44 | 44 | (c2d/set-color canvas
|
45 | 45 | 240 240 240
|
|
48 | 48 | (c2d/set-color canvas 240 180 40 (abs (m/* 180 (m/sin (m/* 1.5 rot-angle)))))
|
49 | 49 | ;(c2d/ellipse canvas 0 0 16 16)
|
50 | 50 | (c2d/rotate canvas (m// m/TWO_PI 5)))
|
51 |
| - ;;බොඳ |
| 51 | + ;;Blur it a bit |
52 | 52 | (p/set-canvas-pixels! canvas
|
53 | 53 | (->> canvas
|
54 | 54 | p/to-pixels
|
55 | 55 | (p/filter-channels p/gaussian-blur-2)))
|
56 |
| - ;;අනෙක් පැත්තට කරකැවීම |
| 56 | + ;;Rotate lotus other way |
57 | 57 | (c2d/rotate canvas (m/- m/TWO_PI))
|
58 | 58 | (c2d/rotate canvas (m/* 4 rot-angle))
|
59 |
| - ;;බාහිර රතු නෙළුම |
| 59 | + ;;Outer red lotus petals |
60 | 60 | (dotimes [_ 6]
|
61 | 61 | (c2d/set-color canvas (m/+ 90 (m/* (m/sin (m// frameno m/TWO_PI 60)) 40)) 0 0 220)
|
62 | 62 | (c2d/shape canvas (:lotus-petal state))
|
63 | 63 | (c2d/rotate canvas (m// m/TWO_PI 6)))
|
64 |
| - ;;බොඳ |
| 64 | + ;;Blur a bit |
65 | 65 | (p/set-canvas-pixels! canvas
|
66 | 66 | (->> canvas
|
67 | 67 | p/to-pixels
|
68 | 68 | (p/filter-channels (p/gaussian-blur 1))))
|
69 | 69 | ;;Reset all translations
|
70 | 70 | (c2d/reset-matrix canvas)
|
71 |
| - ;;තිත් (noise) |
| 71 | + ;;noise |
72 | 72 | (-> canvas
|
73 | 73 | (c2d/image ((:noises state) (mod frameno 20))))
|
74 | 74 | ;;Framerate display
|
75 | 75 | (-> canvas
|
76 | 76 | (c2d/set-color 0 0 0)
|
77 | 77 | (c2d/set-stroke 1)
|
78 |
| - (c2d/text (format "%f" frame-rate) 20 20 :left)) |
| 78 | + (c2d/text (str frame-rate) 20 20 :left)) |
79 | 79 | ;;Title
|
80 | 80 | #_(-> canvas
|
81 | 81 | (c2d/scale 2)
|
82 | 82 | (c2d/set-color 180 160 80 220)
|
83 |
| - (c2d/text "මණ්ඩල" 40 40 :center)) |
| 83 | + (c2d/text "Mandala" 40 40 :center)) |
84 | 84 | ;;Output images
|
85 | 85 | #_(when (:to-video? state)
|
86 | 86 | (c2d/save canvas (str "out/petals" frameno ".jpg"))
|
|
93 | 93 |
|
94 | 94 | (def window
|
95 | 95 | (c2d/show-window {:canvas (c2d/canvas 600 600 :high)
|
96 |
| - :window-name "මණ්ඩල" |
| 96 | + :window-name "mandala" |
97 | 97 | :hint :mid
|
98 | 98 | :always-on-top? true
|
99 | 99 | :position [0 0]
|
|
106 | 106 | :outer-radius 116
|
107 | 107 | :noises (vec (repeatedly 20 #(o/noise-overlay 300 300 {:alpha 25})))
|
108 | 108 | :spots (o/spots-overlay 50 50 {:alpha 100 :intensities [10 20 30 40 50]})
|
109 |
| - ;;නෙලුම් පෙත්ත |
110 | 109 | :lotus-petal (c2d/path-def->shape
|
111 | 110 | [[:move [0 50]]
|
112 | 111 | [:cubic [-8 50 -16 44 -25 44]]
|
|
116 | 115 | [:line [25 44]]
|
117 | 116 | [:cubic [16 44 8 50 0 50]]
|
118 | 117 | [:close]])
|
119 |
| - ;;ඉද්ද පෙත්ත |
120 | 118 | :idda-petal (c2d/path-def->shape
|
121 | 119 | [[:move [0 0]]
|
122 | 120 | [:cubic [-16 20 -35 45 0 50]]
|
|
0 commit comments