Add a demo for orx-gui
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
sourceSets {
|
||||
demo {
|
||||
java {
|
||||
srcDirs = ["src/demo/kotlin"]
|
||||
compileClasspath += main.getCompileClasspath()
|
||||
runtimeClasspath += main.getRuntimeClasspath()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":orx-parameters")
|
||||
api project(":orx-panel")
|
||||
implementation "org.openrndr:openrndr-dialogs:$openrndrVersion"
|
||||
implementation "com.google.code.gson:gson:$gsonVersion"
|
||||
|
||||
demoImplementation("org.openrndr:openrndr-core:$openrndrVersion")
|
||||
demoRuntimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion")
|
||||
demoRuntimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion")
|
||||
demoImplementation(sourceSets.getByName("main").output)
|
||||
}
|
||||
34
orx-gui/src/demo/kotlin/DemoSimple01.kt
Normal file
34
orx-gui/src/demo/kotlin/DemoSimple01.kt
Normal file
@@ -0,0 +1,34 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.gui.GUI
|
||||
import org.openrndr.extra.parameters.ColorParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.Vector2Parameter
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
/**
|
||||
* A simple demonstration of a GUI for drawing a single circle
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
val gui = GUI()
|
||||
val settings = @Description("Settings") object {
|
||||
@DoubleParameter("radius", 0.0, 100.0)
|
||||
var radius = 50.0
|
||||
|
||||
@Vector2Parameter("position", 0.0, 1.0)
|
||||
var position = Vector2.ZERO
|
||||
|
||||
@ColorParameter("color")
|
||||
var color = ColorRGBa.PINK
|
||||
|
||||
}
|
||||
gui.add(settings)
|
||||
extend(gui)
|
||||
extend {
|
||||
drawer.fill = settings.color
|
||||
drawer.circle(settings.position * drawer.bounds.position(1.0, 1.0), settings.radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user