You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/indexed-types/conclusions.md
+22-5Lines changed: 22 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ Also see @duregard12:feat for an approach specialized to enumerating algebraic d
22
22
More recently machine learning techniques are being explored. See, for example, @reddy20:rlcheck and @lemieux23:codamosa.
23
23
@goldstein24:practice studies how property based testing is used in practice.
24
24
25
-
I mentioned that the probability monad can be used in generative art. Generative art is, broadly, art that is generated by some algorithmic process. This can include an element of randomness. While there are papers on generative art (e.g. [@boden09:generative; @dorin12:generative]), and many other resources that discuss it, it's much more fun to create some yourself. Figure [@fig:indexed-types:cycloid] shows an example of generative art, though this example is not one that uses randomness. The code is below, and it has many knobs that you can play with to create your own example. Just add the `@main` annotation to the `cycloid` method and you can run the code from the Scala CLI. Have fun!
25
+
I mentioned that the probability monad can be used in generative art. Generative art is, broadly, art that is generated by some algorithmic process. This can include an element of randomness. While there are papers on generative art (e.g. [@boden09:generative; @dorin12:generative]), and many other resources that discuss it, it's much more fun to create some yourself. Figure [@fig:indexed-types:cycloid] shows an example of generative art. The code is below, and it has many knobs that you can play with to create your own example. Just add the `@main` annotation to the `cycloid` method and you can run the code from the Scala CLI. Have fun!
26
26
27
27
{#fig:indexed-types:cycloid}
28
28
@@ -34,9 +34,10 @@ import cats.syntax.all.*
34
34
importcats.effect.unsafe.implicits.global
35
35
importdoodle.core.*
36
36
importdoodle.core.format.{Pdf, Png}
37
+
importdoodle.interact.syntax.interpolation.*
38
+
importdoodle.random.{*, given}
37
39
importdoodle.syntax.all.*
38
40
importdoodle.java2d.*
39
-
importdoodle.interact.syntax.interpolation.*
40
41
41
42
defcycloid():Unit= {
42
43
givenMonoid[Angle=>Vec] with {
@@ -75,6 +76,18 @@ def cycloid(): Unit = {
75
76
.andThen(phase(90.degrees))
76
77
.andThen(radius(0.33* amplitude)))
77
78
79
+
valrandomCycloid:Random[Double=>Angle=>Vec] =
80
+
for {
81
+
d <-Random.int(3, 25) // Degree of symmetry
82
+
n <-Random.natural(d) // Offset from d
83
+
m1 <-Random.int(1, 5)
84
+
m2 <-Random.int(m1, m1 +5)
85
+
} yield amplitude =>
86
+
cycloid(n, amplitude) |+| cycloid(
87
+
m1 * d + n,
88
+
0.5* amplitude
89
+
) |+| phase(90.degrees).andThen(cycloid(m2 * d + n, 0.33* amplitude))
90
+
78
91
defdrawCycloid(
79
92
cycloid: Angle=>Vec,
80
93
start: Angle=0.degrees,
@@ -89,16 +102,20 @@ def cycloid(): Unit = {
89
102
.toList
90
103
)
91
104
92
-
valpicture=
105
+
/** Repeatedly draw a cycloid with increasing size and a slow turn */
0 commit comments