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:
Abe Pazos
2025-01-26 20:57:04 +01:00
parent 1975a820fc
commit c8f7dd52c6
116 changed files with 2889 additions and 2942 deletions

View File

@@ -8,39 +8,37 @@ import kotlin.math.cos
/**
* Live-coding with [oliveProgram]
*/
fun main() {
application {
configure {
width = 1280
height = 720
}
oliveProgram {
extend {
drawer.clear(ColorRGBa.PINK)
drawer.fill = ColorRGBa.WHITE
for (i in 0 until 100) {
drawer.circle(
width / 2.0 + cos(seconds + i) * 320.0,
i * 7.2,
cos(i + seconds * 0.5) * 20.0 + 20.0
)
}
}
}
// -- this is only needed for the automated screenshots
.olive.scriptLoaded.listen {
if (System.getProperty("takeScreenshot") == "true") {
// -- this is a bit of hack, we need to push the screenshot extension in front of the olive one
fun <T : Extension> extendHead(extension: T, configure: T.() -> Unit): T {
program.extensions.add(0, extension)
extension.configure()
extension.setup(program)
return extension
}
extendHead(SingleScreenshot()) {
this.outputFile = System.getProperty("screenshotPath")
}
}
}
fun main() = application {
configure {
width = 1280
height = 720
}
}
oliveProgram {
extend {
drawer.clear(ColorRGBa.PINK)
drawer.fill = ColorRGBa.WHITE
for (i in 0 until 100) {
drawer.circle(
width / 2.0 + cos(seconds + i) * 320.0,
i * 7.2,
cos(i + seconds * 0.5) * 20.0 + 20.0
)
}
}
}
// -- this is only needed for the automated screenshots
.olive.scriptLoaded.listen {
if (System.getProperty("takeScreenshot") == "true") {
// -- this is a bit of hack, we need to push the screenshot extension in front of the olive one
fun <T : Extension> extendHead(extension: T, configure: T.() -> Unit): T {
program.extensions.add(0, extension)
extension.configure()
extension.setup(program)
return extension
}
extendHead(SingleScreenshot()) {
this.outputFile = System.getProperty("screenshotPath")
}
}
}
}