Add orx-keyframer
This commit is contained in:
23
orx-keyframer/src/demo/kotlin/DemoFull01.kt
Normal file
23
orx-keyframer/src/demo/kotlin/DemoFull01.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.extra.keyframer.Keyframer
|
||||
import org.openrndr.extra.keyframer.KeyframerFormat
|
||||
import org.openrndr.resourceUrl
|
||||
import java.net.URL
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
class Animation: Keyframer() {
|
||||
val position by Vector2Channel(arrayOf("x", "y"))
|
||||
val radius by DoubleChannel("radius")
|
||||
val color by RGBChannel(arrayOf("r", "g", "b"))
|
||||
}
|
||||
val animation = Animation()
|
||||
animation.loadFromJson(URL(resourceUrl("/demo-full-01.json")), format = KeyframerFormat.FULL)
|
||||
|
||||
extend {
|
||||
animation(seconds)
|
||||
drawer.fill = animation.color
|
||||
drawer.circle(animation.position, animation.radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
47
orx-keyframer/src/demo/kotlin/DemoScrub01.kt
Normal file
47
orx-keyframer/src/demo/kotlin/DemoScrub01.kt
Normal file
@@ -0,0 +1,47 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.extra.keyframer.Keyframer
|
||||
import org.openrndr.panel.controlManager
|
||||
import org.openrndr.panel.elements.Range
|
||||
import org.openrndr.panel.elements.Slider
|
||||
import org.openrndr.panel.elements.slider
|
||||
import org.openrndr.resourceUrl
|
||||
import java.net.URL
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
// -- replace the default clock with an offset clock
|
||||
var clockOffset = 0.0
|
||||
val oldClock = clock
|
||||
clock = { oldClock() - clockOffset }
|
||||
var clockSlider: Slider? = null
|
||||
|
||||
// -- setup a simple UI
|
||||
val cm = controlManager {
|
||||
layout {
|
||||
clockSlider = slider {
|
||||
range = Range(0.0, 30.0)
|
||||
events.valueChanged.listen {
|
||||
if (it.interactive) {
|
||||
clockOffset = oldClock() - it.newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
extend(cm)
|
||||
|
||||
class Animation: Keyframer() {
|
||||
val position by Vector2Channel(arrayOf("x", "y"))
|
||||
}
|
||||
val animation = Animation()
|
||||
animation.loadFromJson(URL(resourceUrl("/demo-simple-01.json")))
|
||||
|
||||
extend {
|
||||
// -- update the slider
|
||||
clockSlider?.value = seconds
|
||||
animation(seconds)
|
||||
drawer.circle(animation.position, 100.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
19
orx-keyframer/src/demo/kotlin/DemoSimple01.kt
Normal file
19
orx-keyframer/src/demo/kotlin/DemoSimple01.kt
Normal file
@@ -0,0 +1,19 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.extra.keyframer.Keyframer
|
||||
import org.openrndr.resourceUrl
|
||||
import java.net.URL
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
class Animation: Keyframer() {
|
||||
val position by Vector2Channel(arrayOf("x", "y"))
|
||||
}
|
||||
val animation = Animation()
|
||||
animation.loadFromJson(URL(resourceUrl("/demo-simple-01.json")))
|
||||
|
||||
extend {
|
||||
animation(seconds)
|
||||
drawer.circle(animation.position, 100.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
21
orx-keyframer/src/demo/kotlin/DemoSimple02.kt
Normal file
21
orx-keyframer/src/demo/kotlin/DemoSimple02.kt
Normal file
@@ -0,0 +1,21 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.extra.keyframer.Keyframer
|
||||
import org.openrndr.resourceUrl
|
||||
import java.net.URL
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
class Animation: Keyframer() {
|
||||
val position by Vector2Channel(arrayOf("x", "y"))
|
||||
val radius by DoubleChannel("radius")
|
||||
val color by RGBChannel(arrayOf("r", "g", "b"))
|
||||
}
|
||||
val animation = Animation()
|
||||
animation.loadFromJson(URL(resourceUrl("/demo-simple-02.json")))
|
||||
extend {
|
||||
animation(seconds)
|
||||
drawer.fill = animation.color
|
||||
drawer.circle(animation.position, animation.radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
22
orx-keyframer/src/demo/kotlin/DemoSimpleExpressions01.kt
Normal file
22
orx-keyframer/src/demo/kotlin/DemoSimpleExpressions01.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.extra.keyframer.Keyframer
|
||||
import org.openrndr.resourceUrl
|
||||
import java.net.URL
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
class Animation : Keyframer() {
|
||||
val position by Vector2Channel(arrayOf("x", "y"))
|
||||
val radius by DoubleChannel("x")
|
||||
}
|
||||
|
||||
val animation = Animation()
|
||||
animation.loadFromJson(URL(resourceUrl("/demo-simple-expressions-01.json")),
|
||||
parameters = mapOf("cycleDuration" to 2.0))
|
||||
|
||||
extend {
|
||||
animation(seconds)
|
||||
drawer.circle(animation.position, animation.radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
20
orx-keyframer/src/demo/kotlin/DemoSimpleRepetitions01.kt
Normal file
20
orx-keyframer/src/demo/kotlin/DemoSimpleRepetitions01.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.extra.keyframer.Keyframer
|
||||
import org.openrndr.resourceUrl
|
||||
import java.net.URL
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
class Animation: Keyframer() {
|
||||
val position by Vector2Channel(arrayOf("x", "y"))
|
||||
val radius by DoubleChannel("x")
|
||||
}
|
||||
val animation = Animation()
|
||||
animation.loadFromJson(URL(resourceUrl("/demo-simple-repetitions-01.json")))
|
||||
|
||||
extend {
|
||||
animation(seconds)
|
||||
drawer.circle(animation.position, animation.radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user