[orx-fcurve] Replace |repeat-block| with (repeat-block)
This commit is contained in:
@@ -8,17 +8,18 @@ import org.openrndr.extra.expressions.evaluateExpression
|
||||
* @param constants a map of constants that is passed to [evaluateExpression]
|
||||
*/
|
||||
fun efcurve(ef: String, constants: Map<String, Double> = emptyMap()): String {
|
||||
val expression = Regex("\\{([^_]+)\\}")
|
||||
|
||||
// IntelliJ falsely reports a redundant escape character. the escape character is required when running the regular
|
||||
// expression on a javascript target. Removing the escape character will result in a `Lone quantifier brackets`
|
||||
// syntax error.
|
||||
|
||||
@Suppress("RegExpRedundantEscape")
|
||||
val repetition = Regex("""\|([^|]+)\|\[([^\[\]]+)\]""")
|
||||
val expression = Regex("\\{([^{}]+)\\}")
|
||||
|
||||
@Suppress("RegExpRedundantEscape")
|
||||
val list = Regex("\\|([^|]+)\\|\\{([^\\[\\]]+)\\}")
|
||||
val repetition = Regex("""\(([^()]+)\)\[([^\[\]]+)\]""")
|
||||
|
||||
@Suppress("RegExpRedundantEscape")
|
||||
val list = Regex("\\(([^()]+)\\)\\{([^\\[\\]]+)\\}")
|
||||
|
||||
/**
|
||||
* perform comment substitution
|
||||
|
||||
@@ -5,7 +5,7 @@ import kotlin.test.assertEquals
|
||||
class TestEFCurve {
|
||||
@Test
|
||||
fun comments() {
|
||||
val text = """M1 |h5 m3|{
|
||||
val text = """M1 (h5 m3){
|
||||
|10.3 # toch wel handig zo'n comment
|
||||
|11.2
|
||||
|14.5
|
||||
@@ -21,13 +21,13 @@ class TestEFCurve {
|
||||
|
||||
@Test
|
||||
fun listExpansion() {
|
||||
assertEquals("M0 L1.0, ${3.0} L1.0, ${6.0}", efcurve("M0 |L1.0, {it}|{3, 6}"))
|
||||
assertEquals("M0 L1.0, ${3.0} L1.0, ${6.0}", efcurve("M0 (L1.0, {it}){3, 6}"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun repetition() {
|
||||
assertEquals("M0 L1.0, 3.0 L1.0, 3.0", efcurve("M0 |L1.0, 3.0|[2]"))
|
||||
assertEquals("M0 L1.0, ${0.0} L1.0, ${1.0}", efcurve("M0 |L1.0, {it}|[2]"))
|
||||
assertEquals("M0 L1.0, ${0.0} L1.0, ${1.0} L1.0, ${0.0} L1.0, ${1.0} L1.0, ${0.0} L1.0, ${1.0}", efcurve("M0 ||L1.0, {it}|[2]|[3]"))
|
||||
assertEquals("M0 L1.0, 3.0 L1.0, 3.0", efcurve("M0 (L1.0, 3.0)[2]"))
|
||||
assertEquals("M0 L1.0, ${0.0} L1.0, ${1.0}", efcurve("M0 (L1.0, {it})[2]"))
|
||||
assertEquals("M0 L1.0, ${0.0} L1.0, ${1.0} L1.0, ${0.0} L1.0, ${1.0} L1.0, ${0.0} L1.0, ${1.0}", efcurve("M0 ((L1.0, {it})[2])[3]"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user