Demos: ensure all use fun main() = application {
- Adjust some demo window sizes. - Replace Random.double by Double.uniform - Tweak some demos so screenshots look more interesting
This commit is contained in:
@@ -10,21 +10,19 @@ import kotlin.random.Random
|
||||
* - Filters the generated points to enforce a minimum distance of 20.0 units between them.
|
||||
* - Visualizes the filtered points as circles with a radius of 10.0 units on the canvas.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val r = Random(0)
|
||||
val points = (0 until 10000).map {
|
||||
drawer.bounds.uniform(random = r)
|
||||
}
|
||||
program {
|
||||
val r = Random(0)
|
||||
val points = (0 until 10000).map {
|
||||
drawer.bounds.uniform(random = r)
|
||||
}
|
||||
val filteredPoints = points.filter(20.0)
|
||||
extend {
|
||||
drawer.circles(filteredPoints, 10.0)
|
||||
}
|
||||
val filteredPoints = points.filter(20.0)
|
||||
extend {
|
||||
drawer.circles(filteredPoints, 10.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,32 +13,29 @@ import kotlin.random.Random
|
||||
* - Rectangles representing the bounds of the cells in the grid.
|
||||
* - Circles representing the generated points.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val r = Random(0)
|
||||
val hashGrid = HashGrid(72.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val r = Random(0)
|
||||
val hashGrid = HashGrid(72.0)
|
||||
|
||||
extend {
|
||||
for (i in 0 until 100) {
|
||||
val p = drawer.bounds.uniform(random = r)
|
||||
if (hashGrid.isFree(p)) {
|
||||
hashGrid.insert(p)
|
||||
}
|
||||
extend {
|
||||
for (i in 0 until 100) {
|
||||
val p = drawer.bounds.uniform(random = r)
|
||||
if (hashGrid.isFree(p)) {
|
||||
hashGrid.insert(p)
|
||||
}
|
||||
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.rectangles(hashGrid.cells().map { it.bounds }.toList())
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.circles(hashGrid.points().map { it.first }.toList(), 36.0)
|
||||
|
||||
}
|
||||
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.rectangles(hashGrid.cells().map { it.bounds }.toList())
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.circles(hashGrid.points().map { it.first }.toList(), 36.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user