[orx-fcurve] improve handling of absolute hold command
This commit is contained in:
@@ -308,11 +308,8 @@ class FCurveBuilder {
|
||||
if (relative) {
|
||||
lineTo(x, cursor.y)
|
||||
} else {
|
||||
val d = x - cursor.x
|
||||
require(d >= 0.0) {
|
||||
"requested to hold until $x, but cursor is already at ${cursor.x}"
|
||||
}
|
||||
lineTo(d, cursor.y)
|
||||
require(segments.isEmpty()) { "absolute hold (H $x) is only allowed when used as first command"}
|
||||
cursor = cursor.copy(x = x)
|
||||
}
|
||||
path += "h$x"
|
||||
}
|
||||
|
||||
@@ -16,4 +16,20 @@ class TestFCurve {
|
||||
assertEquals(10.5, normalizedSampler(1.0))
|
||||
assertEquals(10.5, normalizedSampler(-1.0))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAbsoluteHold() {
|
||||
run {
|
||||
val text = "H-1 L 5 5"
|
||||
val fc = fcurve(text)
|
||||
assertEquals(0.0, fc.value(-1.0))
|
||||
assertEquals(5.0, fc.value(4.0))
|
||||
}
|
||||
run {
|
||||
val text = "H1 L 5 5"
|
||||
val fc = fcurve(text)
|
||||
assertEquals(0.0, fc.value(1.0))
|
||||
assertEquals(5.0, fc.value(6.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user