prettifying

This commit is contained in:
Alexey 2025-09-30 14:27:50 +03:00
commit 3510da0428

View file

@ -39,9 +39,9 @@ fun distanceString(targetMeters: Int): AnnotatedString {
withStyle(ParagraphStyle(textAlign = TextAlign.Center)) { withStyle(ParagraphStyle(textAlign = TextAlign.Center)) {
withStyle(SpanStyle(color = Color.White)) { withStyle(SpanStyle(color = Color.White)) {
val text = if (targetMeters >= 100000) val text = if (targetMeters >= 100000)
"${targetMeters / 1000}km" "${targetMeters / 1000}km"
else else
"${targetMeters}m" "${targetMeters}m"
append(text) append(text)
} }
} }
@ -222,13 +222,12 @@ fun MapCanvas(
end = Offset(halvedX, halvedY) end = Offset(halvedX, halvedY)
) )
val startHeight = KhmParser.getHeight(pointLon, pointLat, ctx) val startHeight = KhmParser.getHeight(pointLon, pointLat, ctx)
if (pointOffsetX >= 0 && pointOffsetY >= 0 && pointOffsetX < size.width && pointOffsetY < size.height) if (pointOffsetX >= 0 && pointOffsetY >= 0 && pointOffsetX < size.width && pointOffsetY < size.height)
drawText( drawText(
textMeasurer = textMeasurer, textMeasurer = textMeasurer,
text = buildAnnotatedString { withStyle(SpanStyle(color = Color.White)) { text = buildAnnotatedString { withStyle(SpanStyle(color = Color.White)) {
append("${startHeight}m") append("${startHeight}m")
} }, } },
topLeft = Offset(pointOffsetX, pointOffsetY - 32) topLeft = Offset(pointOffsetX, pointOffsetY - 32)
) )
@ -268,7 +267,7 @@ fun MapCanvas(
text = distanceString(lineMeters), text = distanceString(lineMeters),
size = Size(160F, 48F), size = Size(160F, 48F),
topLeft = Offset( topLeft = Offset(
halvedX, halvedX - 80F,
halvedY - 80F halvedY - 80F
) )
) )
@ -291,15 +290,19 @@ fun MapCanvas(
style = Stroke(width = 6F) style = Stroke(width = 6F)
) )
// Height under cursor // Height under cursor
KhmParser.getHeight(lon, lat, ctx).let {
if (it < 1u) return@let
drawText( drawText(
textMeasurer = textMeasurer, textMeasurer = textMeasurer,
text = buildAnnotatedString { text = buildAnnotatedString {
withStyle(SpanStyle(color = Color.White)) { withStyle(SpanStyle(color = Color.White)) {
append("${KhmParser.getHeight(lon, lat, ctx)}m") append("${it}m")
} }
}, },
topLeft = Offset(halvedX + crossRadius, halvedY + crossRadius) topLeft = Offset(halvedX, halvedY + crossRadius)
) )
}
// Info box // Info box
drawRect( drawRect(
@ -307,7 +310,6 @@ fun MapCanvas(
size = latLonSize, size = latLonSize,
topLeft = latLonOffset topLeft = latLonOffset
) )
// Info box content // Info box content
drawText( drawText(
textMeasurer = textMeasurer, textMeasurer = textMeasurer,
@ -336,14 +338,12 @@ fun MapCanvas(
relativeLineTo(-2F * targetPixels.toFloat(), 0F) relativeLineTo(-2F * targetPixels.toFloat(), 0F)
close() close()
} }
// Distance measurer // Distance measurer
drawPath( drawPath(
measurerPath, measurerPath,
Color.White, Color.White,
style = Stroke(width = 6F) style = Stroke(width = 6F)
) )
// Distance measurer text // Distance measurer text
drawText( drawText(
textMeasurer = textMeasurer, textMeasurer = textMeasurer,