Fix scheme rectangle bug

This commit is contained in:
Alexander Nozik 2022-09-17 13:11:49 +03:00
parent b68fa02fa4
commit c82f47a786
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
3 changed files with 8 additions and 6 deletions

View File

@ -11,6 +11,7 @@ import center.sciprog.maps.scheme.*
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlin.math.PI
@Composable @Composable
@Preview @Preview
@ -31,6 +32,7 @@ fun App() {
text(410.52737 to 868.7676, "Shire", color = Color.Blue) text(410.52737 to 868.7676, "Shire", color = Color.Blue)
circle(1132.0881 to 394.99127, color = Color.Red) circle(1132.0881 to 394.99127, color = Color.Red)
text(1132.0881 to 394.99127, "Ordruin", color = Color.Red) text(1132.0881 to 394.99127, "Ordruin", color = Color.Red)
arc(center = 1132.0881 to 394.99127, radius = 10f, startAngle = 0f, 2 * PI.toFloat())
val hobbitId = circle(410.52737 to 868.7676) val hobbitId = circle(410.52737 to 868.7676)

View File

@ -14,8 +14,8 @@ data class SchemeRectangle(
) { ) {
companion object { companion object {
fun square(center: SchemeCoordinates, height: Float, width: Float): SchemeRectangle = SchemeRectangle( fun square(center: SchemeCoordinates, height: Float, width: Float): SchemeRectangle = SchemeRectangle(
SchemeCoordinates(center.x - width / 2, center.y - height / 2), SchemeCoordinates(center.x - width / 2, center.y + height / 2),
SchemeCoordinates(center.x + width / 2, center.y + height / 2), SchemeCoordinates(center.x + width / 2, center.y - height / 2),
) )
} }
} }
@ -31,8 +31,8 @@ val SchemeRectangle.height get() = abs(a.y - b.y)
val SchemeRectangle.center get() = SchemeCoordinates((a.x + b.x) / 2, (a.y + b.y) / 2) val SchemeRectangle.center get() = SchemeCoordinates((a.x + b.x) / 2, (a.y + b.y) / 2)
public val SchemeRectangle.topLeft: SchemeCoordinates get() = SchemeCoordinates(top, left) public val SchemeRectangle.leftTop: SchemeCoordinates get() = SchemeCoordinates(left, top)
public val SchemeRectangle.bottomRight: SchemeCoordinates get() = SchemeCoordinates(bottom, right) public val SchemeRectangle.rightBottom: SchemeCoordinates get() = SchemeCoordinates(right, bottom)
fun Collection<SchemeRectangle>.wrapAll(): SchemeRectangle? { fun Collection<SchemeRectangle>.wrapAll(): SchemeRectangle? {
if (isEmpty()) return null if (isEmpty()) return null

View File

@ -171,8 +171,8 @@ public fun SchemeView(
is SchemeLineFeature -> drawLine(feature.color, feature.a.toOffset(), feature.b.toOffset()) is SchemeLineFeature -> drawLine(feature.color, feature.a.toOffset(), feature.b.toOffset())
is SchemeArcFeature -> { is SchemeArcFeature -> {
val topLeft = feature.oval.topLeft.toOffset() val topLeft = feature.oval.leftTop.toOffset()
val bottomRight = feature.oval.bottomRight.toOffset() val bottomRight = feature.oval.rightBottom.toOffset()
val path = Path().apply { val path = Path().apply {
addArcRad( addArcRad(