Tweak orx-gui demos to produce better screenshots

This commit is contained in:
Abe Pazos
2020-04-27 18:04:49 +02:00
committed by Edwin Jakobs
parent 975ea5ae0a
commit 03be8b9140
2 changed files with 23 additions and 15 deletions

View File

@@ -3,24 +3,24 @@ import org.openrndr.color.ColorRGBa
import org.openrndr.extensions.SingleScreenshot import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.gui.GUI import org.openrndr.extra.gui.GUI
import org.openrndr.extra.parameters.* import org.openrndr.extra.parameters.*
import org.openrndr.math.Vector2
/** /**
* A simple demonstration of a GUI for drawing a single circle * A simple demonstration of a GUI with a drop down menu
*/ */
enum class SomeOptions { enum class BackgroundColors {
Default, Pink,
DoNothing, Black,
Smile Yellow
} }
fun main() = application { fun main() = application {
program { program {
val gui = GUI() val gui = GUI()
gui.compartmentsCollapsedByDefault = false
val settings = @Description("Settings") object { val settings = @Description("Settings") object {
@OptionParameter("action") @OptionParameter("Background color")
var option = SomeOptions.Default var option = BackgroundColors.Pink
} }
gui.add(settings) gui.add(settings)
@@ -32,9 +32,9 @@ fun main() = application {
extend(gui) extend(gui)
extend { extend {
when(settings.option) { when(settings.option) {
SomeOptions.Default -> drawer.background(ColorRGBa.PINK) BackgroundColors.Pink -> drawer.background(ColorRGBa.PINK)
SomeOptions.DoNothing -> drawer.background(ColorRGBa.BLACK) BackgroundColors.Black -> drawer.background(ColorRGBa.BLACK)
SomeOptions.Smile -> drawer.background(ColorRGBa.YELLOW) BackgroundColors.Yellow -> drawer.background(ColorRGBa.YELLOW)
} }
} }
} }

View File

@@ -4,25 +4,28 @@ import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.gui.GUI import org.openrndr.extra.gui.GUI
import org.openrndr.extra.parameters.* import org.openrndr.extra.parameters.*
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Circle
/** /**
* A simple demonstration of a GUI for drawing a single circle * A simple demonstration of a GUI for drawing some circles
*/ */
fun main() = application { fun main() = application {
program { program {
val gui = GUI() val gui = GUI()
gui.compartmentsCollapsedByDefault = false
val settings = @Description("Settings") object { val settings = @Description("Settings") object {
@DoubleParameter("radius", 0.0, 100.0) @DoubleParameter("radius", 0.0, 100.0)
var radius = 50.0 var radius = 50.0
@Vector2Parameter("position", 0.0, 1.0) @Vector2Parameter("position", 0.0, 1.0)
var position = Vector2.ZERO var position = Vector2(0.6, 0.5)
@ColorParameter("color") @ColorParameter("color")
var color = ColorRGBa.PINK var color = ColorRGBa.PINK
@DoubleListParameter("a double list") @DoubleListParameter("radii", 5.0, 30.0)
var adl = MutableList(2) { 0.0 } var radii = mutableListOf(5.0, 6.0, 8.0, 14.0, 20.0, 30.0)
} }
gui.add(settings) gui.add(settings)
if (System.getProperty("takeScreenshot") == "true") { if (System.getProperty("takeScreenshot") == "true") {
@@ -34,6 +37,11 @@ fun main() = application {
extend { extend {
drawer.fill = settings.color drawer.fill = settings.color
drawer.circle(settings.position * drawer.bounds.position(1.0, 1.0), settings.radius) drawer.circle(settings.position * drawer.bounds.position(1.0, 1.0), settings.radius)
drawer.circles(
settings.radii.mapIndexed { i, radius ->
Circle(width - 50.0, 60.0 + i * 70.0, radius)
}
)
} }
} }
} }