Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LP-1040 and LP-1041 #1052

Merged
merged 9 commits into from
Mar 21, 2024
Prev Previous commit
Next Next commit
Fix arrows on curves
  • Loading branch information
IKupriyanov-HORIS committed Mar 20, 2024
commit 8279e9fe723b48e4b8ec5d748737e3935c3ddf9b
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class ArrowSpec(
arrowSpec: ArrowSpec
): Pair<List<DoubleVector>, List<DoubleVector>> {
val startHead = when (arrowSpec.isOnFirstEnd) {
true -> createArrowHeadGeometry(arrowSpec, geometry.take(2).reversed())
true -> createArrowHeadGeometry(arrowSpec, geometry.asReversed())
false -> emptyList()
}

val endHead = when (arrowSpec.isOnLastEnd) {
true -> createArrowHeadGeometry(arrowSpec, geometry.takeLast(2))
true -> createArrowHeadGeometry(arrowSpec, geometry)
false -> emptyList()
}

Expand All @@ -68,9 +68,10 @@ class ArrowSpec(
): List<DoubleVector> {
if (geometry.size < 2) return emptyList()

// Shorten the arrow head if the segment is shorter than the arrow head
val headLength = when {
geometry.size == 2 -> min(arrowSpec.length, distance(geometry[0], geometry[1]))
else -> arrowSpec.length
else -> arrowSpec.length // yet not implemented for multi-segment lines (e.g. curves), so use full length
}

val basePoint = geometry[geometry.lastIndex - 1]
Expand Down