Add descriptions to demos
This commit is contained in:
@@ -2,18 +2,29 @@ import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.gui.GUI
|
||||
import org.openrndr.extra.gui.GUIAppearance
|
||||
import org.openrndr.extra.parameters.*
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.extra.parameters.ColorParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.panel.elements.draw
|
||||
|
||||
|
||||
/**
|
||||
* A simple demonstration of a GUI for drawing some circles
|
||||
* Demonstrates the `GUI.enableSideCanvas` feature.
|
||||
*
|
||||
* When set to true, the `GUI` provides a `canvas` property where one can draw.
|
||||
* The size of this canvas is the window size minus the GUI size.
|
||||
*
|
||||
* That's why if we draw a circle at `drawer.width / 2.0` it is centered
|
||||
* on the `canvas`, not on the window.
|
||||
*
|
||||
* This demo sets the window to resizable, so if you resize the window
|
||||
* you should see tha the circle stays at the center of the canvas.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
windowResizable = true
|
||||
}
|
||||
|
||||
@@ -23,17 +34,11 @@ fun main() = application {
|
||||
gui.enableSideCanvas = true
|
||||
|
||||
val settings = @Description("Settings") object {
|
||||
@DoubleParameter("radius", 0.0, 100.0)
|
||||
@DoubleParameter("radius", 0.0, 200.0)
|
||||
var radius = 50.0
|
||||
|
||||
@Vector2Parameter("position", 0.0, 1.0)
|
||||
var position = Vector2(0.6, 0.5)
|
||||
|
||||
@ColorParameter("color")
|
||||
var color = ColorRGBa.PINK
|
||||
|
||||
@DoubleListParameter("radii", 5.0, 30.0)
|
||||
var radii = mutableListOf(5.0, 6.0, 8.0, 14.0, 20.0, 30.0)
|
||||
}
|
||||
gui.add(settings)
|
||||
extend(gui)
|
||||
@@ -42,7 +47,7 @@ fun main() = application {
|
||||
val width = drawer.width
|
||||
val height = drawer.height
|
||||
drawer.fill = settings.color
|
||||
drawer.circle(width/2.0, height/2.0, 100.0)
|
||||
drawer.circle(width / 2.0, height / 2.0, settings.radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user