42 lines
1.1 KiB
Kotlin
42 lines
1.1 KiB
Kotlin
import org.openrndr.application
|
|
import org.openrndr.extra.gui.GUI
|
|
import org.openrndr.extra.parameters.Description
|
|
import org.openrndr.extra.parameters.XYParameter
|
|
import org.openrndr.math.Vector2
|
|
|
|
/**
|
|
* Demonstrates the use of the `@XYParameter` annotation applied to a `Vector2` variable.
|
|
*
|
|
* This annotation creates an interactive XY control in a GUI that can be used to update
|
|
* a `Vector2` variable. In this demo it sets the position of a circle.
|
|
*
|
|
*/
|
|
fun main() = application {
|
|
configure {
|
|
width = 800
|
|
height = 800
|
|
}
|
|
|
|
program {
|
|
val gui = GUI()
|
|
gui.compartmentsCollapsedByDefault = false
|
|
|
|
val settings = @Description("Settings") object {
|
|
@XYParameter(
|
|
"Position", 0.0, 800.0, 0.0, 800.0,
|
|
precision = 2,
|
|
invertY = false,
|
|
showVector = true
|
|
)
|
|
var position: Vector2 = Vector2(0.0, 0.0)
|
|
}
|
|
|
|
gui.add(settings)
|
|
|
|
extend(gui)
|
|
extend {
|
|
drawer.circle(settings.position, 50.0)
|
|
}
|
|
}
|
|
}
|