-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[orx-olive] Add DemoWindowedGUI01.kt
- Loading branch information
Showing
5 changed files
with
130 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,46 @@ | ||
import org.openrndr.Extension | ||
import org.openrndr.Program | ||
import org.openrndr.application | ||
|
||
import org.openrndr.color.ColorRGBa | ||
import org.openrndr.extensions.SingleScreenshot | ||
import org.openrndr.extra.olive.Olive | ||
|
||
fun main() = application { | ||
configure { | ||
width = 768 | ||
height = 576 | ||
} | ||
program { | ||
import org.openrndr.extra.olive.oliveProgram | ||
import kotlin.math.cos | ||
|
||
extend(Olive<Program>()) { | ||
script = "orx-olive/src/demo/kotlin/demo-olive-01.kts" | ||
// -- this block is for automation purposes only | ||
if (System.getProperty("takeScreenshot") == "true") { | ||
scriptLoaded.listen { | ||
/** | ||
* Live-coding with [oliveProgram] | ||
*/ | ||
fun main() { | ||
application { | ||
configure { | ||
width = 1280 | ||
height = 720 | ||
} | ||
oliveProgram { | ||
extend { | ||
drawer.clear(ColorRGBa.GRAY) | ||
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> Program.extendHead(extension: T, configure: T.() -> Unit): T { | ||
extensions.add(0, extension) | ||
fun <T : Extension> extendHead(extension: T, configure: T.() -> Unit): T { | ||
program.extensions.add(0, extension) | ||
extension.configure() | ||
extension.setup(this) | ||
extension.setup(program) | ||
return extension | ||
} | ||
extendHead(SingleScreenshot()) { | ||
this.outputFile = System.getProperty("screenshotPath") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
orx-jvm/orx-olive/src/demo/kotlin/DemoOliveFromScript01.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import org.openrndr.Extension | ||
import org.openrndr.Program | ||
import org.openrndr.application | ||
|
||
import org.openrndr.extensions.SingleScreenshot | ||
import org.openrndr.extra.olive.Olive | ||
|
||
/** | ||
* Live-coding with [Olive], an older, not recommended, way to do things | ||
*/ | ||
fun main() = application { | ||
configure { | ||
width = 768 | ||
height = 576 | ||
} | ||
program { | ||
|
||
extend(Olive<Program>()) { | ||
script = "orx-olive/src/demo/kotlin/demo-olive-01.kts" | ||
// -- this block is for automation purposes only | ||
if (System.getProperty("takeScreenshot") == "true") { | ||
scriptLoaded.listen { | ||
// -- this is a bit of hack, we need to push the screenshot extension in front of the olive one | ||
fun <T : Extension> Program.extendHead(extension: T, configure: T.() -> Unit): T { | ||
extensions.add(0, extension) | ||
extension.configure() | ||
extension.setup(this) | ||
return extension | ||
} | ||
extendHead(SingleScreenshot()) { | ||
this.outputFile = System.getProperty("screenshotPath") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
44 changes: 0 additions & 44 deletions
44
orx-jvm/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import org.openrndr.application | ||
import org.openrndr.color.ColorRGBa | ||
import org.openrndr.extra.gui.WindowedGUI | ||
import org.openrndr.extra.olive.oliveProgram | ||
import org.openrndr.extra.parameters.ColorParameter | ||
import org.openrndr.extra.parameters.Description | ||
import org.openrndr.extra.parameters.DoubleParameter | ||
import org.openrndr.extra.parameters.IntParameter | ||
import kotlin.math.cos | ||
import kotlin.system.exitProcess | ||
|
||
/** | ||
* Live-coding with [oliveProgram] and [WindowedGUI] | ||
*/ | ||
fun main() { | ||
// skip this demo on CI | ||
if (System.getProperty("takeScreenshot") == "true") { | ||
exitProcess(0) | ||
} | ||
application { | ||
configure { | ||
width = 720 | ||
height = 720 | ||
} | ||
oliveProgram() { | ||
val gui = WindowedGUI() | ||
|
||
val settings = @Description("Settings") object { | ||
@DoubleParameter("radius", 0.0, 80.0) | ||
var radius = 30.0 | ||
|
||
@ColorParameter("color") | ||
var fill = ColorRGBa.RED | ||
|
||
@ColorParameter("background") | ||
var background = ColorRGBa.BLACK | ||
|
||
@DoubleParameter("speed", 0.1, 10.0) | ||
var speed = 1.0 | ||
|
||
@IntParameter("count", 1, 400) | ||
var count = 100 | ||
} | ||
gui.add(settings) | ||
|
||
extend(gui) | ||
extend { | ||
drawer.clear(settings.background) | ||
drawer.fill = settings.fill | ||
for (i in 0 until settings.count) { | ||
drawer.circle( | ||
width / 2.0 + cos(settings. speed * seconds + i) * 320.0, | ||
i * 7.2, | ||
(cos(i + seconds * 0.5) * 1.0 + 1.0) * settings.radius | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |