Skip to content

Commit 7fed59f

Browse files
author
Duminda Rathnayaka
committed
Minor changes to comments, added in readme ex66
1 parent 4da575b commit 7fed59f

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ In Emacs/Cider: C-c C-k
7676
* ex63 - Particle life
7777
* ex64 - Particle lenia
7878
* ex65 - Reaction-Diffusion
79+
* ex66 - Flower mandala
7980
* NOC - [Nature of Code](https://github.com/shiffman/The-Nature-of-Code-Examples/) Clojure2d version. Most interesting:
8081
* ch02/attraction-many-2-7.clj
8182
* ch02/fluidresistance-2-5.clj

src/ex65_spinning_flower_mandala.clj renamed to src/ex66_spinning_flower_mandala.clj

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(ns ex65-spinning-flower-mandala
1+
(ns ex66-spinning-flower-mandala
22
(:require [clojure2d.core :as c2d]
33
[clojure2d.pixels :as p]
44
[clojure2d.extra.overlays :as o]
@@ -18,13 +18,13 @@
1818
frame-rate (m// (m/* frameno 1000000000.0) elapsed-time)
1919
o-r (m/* 2 (m/+ outer-radius (m/* 5 (m/sin (m// frameno m/TWO_PI 5)))))
2020
rot-angle (m/mod (m// frameno m/TWO_PI 60) m/TWO_PI)]
21-
;;ඛණ්ඩාංක පද්ධතිය සෙටප් කිරීම
21+
;;Translate and setup coords
2222
(-> canvas
2323
(c2d/scale 2)
2424
(c2d/translate 150 150)
2525
(c2d/rotate rot-angle)
2626
(c2d/flip-y))
27-
;;කහ පැහැ පල්ස් වෙන රැස් මාලාව
27+
;;Back halo
2828
(-> canvas
2929
(c2d/set-color 116 88 20 120)
3030
(c2d/ellipse 0 0 o-r o-r)
@@ -34,12 +34,12 @@
3434
(c2d/ellipse 0 0 (m/- o-r 8) (m/- o-r 8))
3535
(c2d/set-color 232 177 40 120)
3636
(c2d/ellipse 0 0 (m/- o-r 8) (m/- o-r 8)))
37-
;;රැස් බොඳ
37+
;;Blur halo
3838
(p/set-canvas-pixels! canvas
3939
(->> canvas
4040
p/to-pixels
4141
(p/filter-channels p/gaussian-blur-5)))
42-
;;මැද ඉද්ද මල
42+
;;Idda flower at the center https://en.wikipedia.org/wiki/Wrightia_antidysenterica
4343
(dotimes [_ 5]
4444
(c2d/set-color canvas
4545
240 240 240
@@ -48,39 +48,39 @@
4848
(c2d/set-color canvas 240 180 40 (abs (m/* 180 (m/sin (m/* 1.5 rot-angle)))))
4949
;(c2d/ellipse canvas 0 0 16 16)
5050
(c2d/rotate canvas (m// m/TWO_PI 5)))
51-
;;බොඳ
51+
;;Blur it a bit
5252
(p/set-canvas-pixels! canvas
5353
(->> canvas
5454
p/to-pixels
5555
(p/filter-channels p/gaussian-blur-2)))
56-
;;අනෙක් පැත්තට කරකැවීම
56+
;;Rotate lotus other way
5757
(c2d/rotate canvas (m/- m/TWO_PI))
5858
(c2d/rotate canvas (m/* 4 rot-angle))
59-
;;බාහිර රතු නෙළුම
59+
;;Outer red lotus petals
6060
(dotimes [_ 6]
6161
(c2d/set-color canvas (m/+ 90 (m/* (m/sin (m// frameno m/TWO_PI 60)) 40)) 0 0 220)
6262
(c2d/shape canvas (:lotus-petal state))
6363
(c2d/rotate canvas (m// m/TWO_PI 6)))
64-
;;බොඳ
64+
;;Blur a bit
6565
(p/set-canvas-pixels! canvas
6666
(->> canvas
6767
p/to-pixels
6868
(p/filter-channels (p/gaussian-blur 1))))
6969
;;Reset all translations
7070
(c2d/reset-matrix canvas)
71-
;;තිත් (noise)
71+
;;noise
7272
(-> canvas
7373
(c2d/image ((:noises state) (mod frameno 20))))
7474
;;Framerate display
7575
(-> canvas
7676
(c2d/set-color 0 0 0)
7777
(c2d/set-stroke 1)
78-
(c2d/text (format "%f" frame-rate) 20 20 :left))
78+
(c2d/text (str frame-rate) 20 20 :left))
7979
;;Title
8080
#_(-> canvas
8181
(c2d/scale 2)
8282
(c2d/set-color 180 160 80 220)
83-
(c2d/text "මණ්ඩල" 40 40 :center))
83+
(c2d/text "Mandala" 40 40 :center))
8484
;;Output images
8585
#_(when (:to-video? state)
8686
(c2d/save canvas (str "out/petals" frameno ".jpg"))
@@ -93,7 +93,7 @@
9393

9494
(def window
9595
(c2d/show-window {:canvas (c2d/canvas 600 600 :high)
96-
:window-name "මණ්ඩල"
96+
:window-name "mandala"
9797
:hint :mid
9898
:always-on-top? true
9999
:position [0 0]
@@ -106,7 +106,6 @@
106106
:outer-radius 116
107107
:noises (vec (repeatedly 20 #(o/noise-overlay 300 300 {:alpha 25})))
108108
:spots (o/spots-overlay 50 50 {:alpha 100 :intensities [10 20 30 40 50]})
109-
;;නෙලුම් පෙත්ත
110109
:lotus-petal (c2d/path-def->shape
111110
[[:move [0 50]]
112111
[:cubic [-8 50 -16 44 -25 44]]
@@ -116,7 +115,6 @@
116115
[:line [25 44]]
117116
[:cubic [16 44 8 50 0 50]]
118117
[:close]])
119-
;;ඉද්ද පෙත්ත
120118
:idda-petal (c2d/path-def->shape
121119
[[:move [0 0]]
122120
[:cubic [-16 20 -35 45 0 50]]

0 commit comments

Comments
 (0)