@@ -48,7 +48,6 @@ fun Segment2D.scaleTangents(axis: Vector2 = Vector2.UNIT_X): Segment2D {
48
48
val c = this .cubic
49
49
val width = end.distanceTo(start)
50
50
51
- val d = c.end - c.start
52
51
val cd0 = (c.control[0 ] - c.start).projectedOn(axis)
53
52
val cd0a = cd0.dot(axis)
54
53
val cd1 = (c.control[1 ] - c.end).projectedOn(- axis)
@@ -220,7 +219,7 @@ data class FCurve(val segments: List<Segment2D>) {
220
219
221
220
/* *
222
221
* Evaluate the Fcurve at [t]
223
- * @param segment an optional segment that can be used to speed up scanning for the relevant segment
222
+ * @param cachedSegment an optional segment that can be used to speed up scanning for the relevant segment
224
223
*/
225
224
fun valueWithSegment (t : Double , cachedSegment : Segment2D ? = null): Pair <Double , Segment2D ?> {
226
225
if (cachedSegment != null ) {
@@ -348,11 +347,9 @@ class FCurveBuilder {
348
347
349
348
if (segments.isNotEmpty()) {
350
349
val lastSegment = segments.last()
351
- val lastDuration = lastSegment.end.x - lastSegment.start.x
352
350
val outTangent = if (segments.last().linear) lastSegment.end else segments.last().control.last()
353
351
val outPos = lastSegment.end
354
352
val d = outPos - outTangent
355
- // val dn = d.normalized
356
353
val ts = 1.0 // x / lastDuration
357
354
segments.add(
358
355
Segment2D (
@@ -417,14 +414,20 @@ fun fcurve(builder: FCurveBuilder.() -> Unit): FCurve {
417
414
return fb.build()
418
415
}
419
416
417
+
420
418
/* *
421
- * Split an Fcurve string in to command parts
419
+ * Splits an input string containing fcurve path commands and numbers into individual components,
420
+ * preserving the order of commands and associated numbers.
421
+ * The splitting considers the relations between commands and numbers, ensuring proper separation.
422
+ *
423
+ * @param d The input string representing fcurve path commands and numbers.
424
+ * @return A list of strings where each element is either an fcurve path command or a related numerical value.
422
425
*/
423
426
fun fCurveCommands (d : String ): List <String > {
424
- val svgCommands = " mMlLqQsStTcChH"
427
+ val fcurveCommands = " mMlLqQsStTcChH"
425
428
val number = " 0-9.\\ -E%"
426
429
427
- return d.split(Regex (" (?:[\t ,]|\r ?\n )+|(?<=[$svgCommands ])(?=[$number ])|(?<=[$number ])(?=[$svgCommands ])" ))
430
+ return d.split(Regex (" (?:[\t ,]|\r ?\n )+|(?<=[$fcurveCommands ])(?=[$number ])|(?<=[$number ])(?=[$fcurveCommands ])" ))
428
431
.filter { it.isNotBlank() }
429
432
}
430
433
0 commit comments