[orx-panel] Fix DemoHorizontalLayout01.kt
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import org.openrndr.application
|
import org.openrndr.application
|
||||||
import org.openrndr.color.ColorRGBa
|
import org.openrndr.color.ColorRGBa
|
||||||
|
import org.openrndr.color.Linearity
|
||||||
import org.openrndr.extensions.SingleScreenshot
|
import org.openrndr.extensions.SingleScreenshot
|
||||||
import org.openrndr.math.Spherical
|
import org.openrndr.math.Spherical
|
||||||
import org.openrndr.math.Vector3
|
import org.openrndr.math.Vector3
|
||||||
@@ -41,40 +42,43 @@ fun main() = application {
|
|||||||
|
|
||||||
div("horizontal") {
|
div("horizontal") {
|
||||||
// A bunch of names for generating buttons
|
// A bunch of names for generating buttons
|
||||||
listOf("load", "save", "redo", "stretch", "bounce",
|
listOf(
|
||||||
"twist", "swim", "roll", "fly", "dance")
|
"load", "save", "redo", "stretch", "bounce",
|
||||||
.forEachIndexed { i, word ->
|
"twist", "swim", "roll", "fly", "dance"
|
||||||
|
)
|
||||||
|
.forEachIndexed { i, word ->
|
||||||
|
|
||||||
// A fun way of generating a set of colors
|
// A fun way of generating a set of colors
|
||||||
// of similar brightness:
|
// of similar brightness:
|
||||||
// Grab a point on the surface of a sphere
|
// Grab a point on the surface of a sphere
|
||||||
// and treat its coordinates as an rgb color.
|
// and treat its coordinates as an rgb color.
|
||||||
val pos = Vector3.fromSpherical(
|
val pos = Vector3.fromSpherical(
|
||||||
Spherical(i * 19.0, i * 17.0, 0.4))
|
Spherical(i * 19.0, i * 17.0, 0.4)
|
||||||
val rgb = ColorRGBa.fromVector(pos + 0.4)
|
)
|
||||||
|
val rgb = ColorRGBa.fromVector(pos + 0.4)
|
||||||
|
|
||||||
button {
|
button {
|
||||||
label = word
|
label = word
|
||||||
style = styleSheet {
|
style = styleSheet {
|
||||||
// Use Color.RGBa() to convert a ColorRGBa
|
// Use Color.RGBa() to convert a ColorRGBa
|
||||||
// color (the standard color datatype)
|
// color (the standard color datatype)
|
||||||
// into "CSS" format:
|
// into "CSS" format:
|
||||||
background = Color.RGBa(rgb)
|
background = Color.RGBa(rgb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the button is clicked replace
|
// When the button is clicked replace
|
||||||
// the header text with the button's label
|
// the header text with the button's label
|
||||||
events.clicked.listen {
|
events.clicked.listen {
|
||||||
header.replaceText(it.source.label)
|
header.replaceText(it.source.label)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extend(cm)
|
extend(cm)
|
||||||
extend {
|
extend {
|
||||||
drawer.clear(0.2, 0.18, 0.16, 1.0)
|
drawer.clear(ColorRGBa(0.2, 0.18, 0.16, 1.0, Linearity.SRGB))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user