[orx-keyframer] Add DoubleArrayChannel

This commit is contained in:
Edwin Jakobs
2020-09-15 14:58:56 +02:00
parent 8e8aef200f
commit 54e9579a6c

View File

@@ -18,7 +18,6 @@ import kotlin.reflect.KProperty1
import kotlin.reflect.full.memberProperties import kotlin.reflect.full.memberProperties
import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.isAccessible
enum class KeyframerFormat { enum class KeyframerFormat {
SIMPLE, SIMPLE,
FULL FULL
@@ -97,6 +96,18 @@ open class Keyframer {
ColorRGBa(getValue(0), getValue(1), getValue(2)) ColorRGBa(getValue(0), getValue(1), getValue(2))
} }
inner class DoubleArrayChannel(keys: Array<String>, defaultValue: DoubleArray = DoubleArray(keys.size)) :
CompoundChannel(keys, defaultValue.toTypedArray()) {
operator fun getValue(keyframer: Keyframer, property: KProperty<*>): DoubleArray {
val result = DoubleArray(keys.size)
for (i in keys.indices) {
result[i] = getValue(i)
}
return result
}
}
val channels = mutableMapOf<String, KeyframerChannel>() val channels = mutableMapOf<String, KeyframerChannel>()
fun loadFromJson( fun loadFromJson(
@@ -125,7 +136,7 @@ open class Keyframer {
loadFromJsonString(url.readText(), format, parameters, functions) loadFromJsonString(url.readText(), format, parameters, functions)
} catch (e: ExpressionException) { } catch (e: ExpressionException) {
throw ExpressionException("Error loading $format from '${url}': ${e.message ?: ""}") throw ExpressionException("Error loading $format from '${url}': ${e.message ?: ""}")
} catch(e: IllegalStateException) { } catch (e: IllegalStateException) {
throw ExpressionException("Error loading $format from '${url}': ${e.message ?: ""}") throw ExpressionException("Error loading $format from '${url}': ${e.message ?: ""}")
} }
} }