Nie*_*orp 5 android kotlin android-jetpack-compose
我正在 Jetpack compose 中为地图中的每个区域使用向量Groups 和s制作国家地图。Path我想要对特定区域的比例进行动画处理,但我很难设置正确的比例pivotX,并且pivotY属于Group应该动画变大和变小的正确区域,导致该区域也在 x 和 y 方向上移动。我的代码如下:
import androidx.compose.animation.core.EaseInOut
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.Group
import androidx.compose.ui.graphics.vector.Path
import androidx.compose.ui.graphics.vector.PathNode
import androidx.compose.ui.graphics.vector.PathParser
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.unit.dp
typealias Province = String
object Netherlands {
val PathMap = mapOf<Province, List<List<PathNode>>>(
"Overijssel" to listOf(
PathParser().parsePathString(
"m144.01 59.386-1.162 0.77493-0.77463 0.77492h-1.162-0.38732l0.38732 0.77492v0.38746h-0.38732l-0.38731 0.38746-0.77463 0.38746v-0.77492l-1.162 0.38746-0.38732 0.38746v-0.38746h-0.38731l-0.38732-0.38746-0.38731-0.77492v-0.77492l-0.77464 0.38746v0.38746l-0.77463-0.38746v0.38746h-0.77463l-0.38732 0.38746v0.38746l-0.38731 0.38746v0.38746l-0.38732 0.38747h-0.38731v0.38746h-0.38732l-0.38732 0.38746h-0.38731-0.38732-0.38731l-0.38732-0.38746h-0.38732-0.38731v-0.38746h-0.38732-0.38731v-0.38747h-0.38732l-0.77463 0.77493 0.38731 0.77492 0.77464 0.77492v0.38746h0.77463 0.77463l0.38732 0.38746 1.1619 0.38747 0.38732 0.77492 0.38732 0.38746h0.38731l0.77463 0.77492 0.38732 1.1624 0.77463 1.5498v0.38746h0.38732l0.38731 0.38746v0.38746l0.38732 0.38747v0.38746 0.38746l-0.77463 0.38746-0.77463 0.77492v0.38746 0.38746h0.38731v-0.38746l0.77463 0.38746h0.38732l0.77463 0.38747 0.38732 0.38746 0.38731 0.38746h0.77463l0.38732 0.77492-0.38732 0.38746-1.1619 0.77492h-0.38732l-1.162 0.38747v0.38746l-0.77463 0.38746h-0.38731l-0.77464 0.38746-0.77463-0.77492-3.0985 0.77492-0.38731 0.38746v0.77492 0.38746 0.38747l0.38731 0.38746v0.38746l-1.5493-0.38746 0.38732 0.38746h0.38731 0.38732v0.38746l0.38731 0.38746v0.38746 0.38746l0.38732 0.38746 0.38732 0.38747v0.38746 0.38746l0.38731 0.38746v0.77492 0.77492l0.77463-0.38746 0.38732 0.38746 0.77463 1.1624 0.38732 0.77492 0.77463 1.1624v0.77493l0.77463-0.38747 0.77463-0.77492v0.38746l0.38732 0.38746 2.3239-2.3248h0.38732 0.38732l0.38731-0.38746 0.38732 0.38746h0.38731l0.77464 0.77492v0.38746 0.38746l0.38731 0.38746 1.162 0.38746 0.38732 0.38747v0.38746l0.38731 1.1624v0.77492l0.38732 0.38746 0.38731 0.38747v0.77492l-0.38731 0.38746v0.38746 0.77492l0.38731 0.38746h0.38732v0.38747 0.38746 0.77492h-0.38732v0.38746h-0.38731l-0.77463 0.38746h-0.77464v0.38746h-0.38731v0.38746l0.38731 0.38747h0.38732l0.38732 0.38746h-0.38732l-0.38732 0.38746h-0.38731v0.77492 0.77492 0.77493h-0.38732v0.38746h0.38732 0.38731v0.38746 1.1624h0.38732 0.38732 0.38731v0.38746 0.38746h0.38732v1.1624l0.77463 0.77492v0.38746 0.38746 0.38746l0.38732 0.38747h0.38731 0.38732 0.38731v0.38746h-0.38731l-0.38732 0.38746v0.38746l0.38732 0.77492h0.38731 0.38732v-0.38746l0.77463-0.38746h0.38732v0.38746h0.77463 0.38731l0.38732 0.38746v-0.38746h0.38732 0.38731 0.38732 0.77463 0.38732l0.38731 0.38746 0.38732-0.38746h0.38731 0.38732 0.38732v0.38746h1.1619v-0.38746h0.77464v-0.77492h0.38731l0.38732-0.38746h0.77463 0.38732l0.38731-0.38746v0.38746h0.38732 0.38731 0.77464 0.38731v0.38746 0.38746l0.38732 0.77492 1.1619 0.77492v0.77493h0.38732v0.38746h0.77463v0.77492l0.38732 0.38746v0.38746h0.38731l0.38732 0.38746 0.77463-0.38746h0.38732l1.9366 0.38746 1.5493-0.38746h0.38732l0.77463 0.38746-0.38732 0.38746 0.77464 0.77493v-0.38746l0.38731-0.38747 0.38732-0.38746 0.38731 0.38746v0.38747l0.38732-0.77493h0.38731l1.162 0.77493v0.38746 0.38746 1.1624l-0.77463 1.1624h0.77463 0.38732l1.5493 0.77492h0.38732 2.3239 3.0985 1.162l0.38731-0.38746 0.77464-0.77493v-0.38746l0.38731-1.9373h0.38732v-0.38746l1.162-0.77493v-0.38746l1.1619-0.38746h1.162l0.38732-0.77492v-0.38746l0.38731-0.38746v-0.38747l0.38732-0.38746v-0.38746-0.38746-0.38746l0.38732-0.38746 0.77463-0.38746 0.38731 0.38746h0.38732 0.38732 0.77463l1.1619-0.77492v-0.38746l-1.1619-1.5498-0.38732-0.38746v-0.77492h-0.38731v-0.38746-0.38747-0.38746-0.38746l0.38731-1.1624v-0.38746h0.38732v-0.38746h0.38731v-0.38747-0.38746l0.38732-0.77492v-0.38746l0.77463-1.1624v-1.9373l-0.77463-1.5498v-0.38746-0.38746h-0.38732-0.38731-0.38732l-0.38731-0.77492-0.38732-0.77492-0.77463-0.77493v-0.38746l-0.38732-0.77492v-0.77492l-0.38731-0.77492v-0.38747h-0.38732-0.38732l-0.38731 0.77493-0.38732 1.1624-0.77463 0.38746v0.38746h-0.38732l-1.9366-0.38746-0.77463-0.38746-1.162-0.38746h-0.77463l0.38732-0.77492h-0.77463-1.162-2.3239-0.77463l-0.38731-0.38746-1.5493-0.77493-0.38731-0.38746-0.77464-0.38746 0.38732-3.0997-0.77463-1.1624-0.77463-1.5498h0.38731l0.77463 0.38746h0.77464l0.38731-1.1624h0.77463l0.77464 0.38746 0.38731-0.38746-2.3239-1.9373v-0.77492l0.38731-1.5498v-0.38746l-0.38731-0.38747-0.38732-0.38746h-0.38732v-0.38746-0.38746-0.38746l0.38732-0.38746-0.38732-0.38746h-0.77463l-3.8732-1.9373v0.38746h-0.38731l-1.162 0.38746h-1.5493l-1.9366 1.9373 0.38731 2.3248v0.38746h-0.38731l-0.38732-0.38746h-0.38732-0.77463l-0.77463-0.77493v0.38747l-0.77463 0.77492-0.38732-0.38746h-0.38731v-0.38746-0.38747h-0.38732l-0.38731 0.38747v0.38746h-0.38732v-0.38746h-0.38732v0.38746h-0.38731-0.38732v0.38746h-0.38731l-0.38732-0.38746v-0.77493l-0.38732-0.38746v-0.38746h-0.38731v-0.38746-0.38746h-0.38732l-0.38731-0.38746h-0.38732l-0.38732-0.38746v-0.38746h-0.38731v-0.38747h0.38731v-0.38746h-0.38731-0.38732l-0.38731 0.38746h-0.38732-0.38732-0.38731v-0.38746h-0.38732v0.38746h-0.38731-0.38732v-0.38746h-0.38732l-0.38731-0.38746v-0.38746h-0.38732-0.38731-0.38732v-0.38746h-0.38732-0.38731-0.38732l-0.38731 0.38746v0.38746l-0.38732-0.38746v-0.38746l-0.38731 0.38746 0.38731 0.38746-1.162-0.38746 0.38732-0.38746v-0.38746l-0.77463-0.38746v-0.38746l-0.77463-1.1624v-0.38746-0.38746l-0.38732-0.77492-0.38732-0.77493-0.38731-0.77492v-0.38746h0.38731l0.38732-0.38746 1.162-0.38746 0.38731-0.38746h0.38732v-0.38746l0.77463-0.77493 0.38732-0.38746 0.38731-0.77492h-0.38731l-0.38732-0.77492-3.0985-3.0997v-0.38746l-0.38731-0.77493zm2.7112 52.695v0.38746 0.38746l0.38732-0.38746-0.38732-0.38746z"
).toNodes()
),
"Gelderland" to listOf(
PathParser().parsePathString(
"m132.01 87.283-0.77463 0.38746v0.38746l-0.38731 1.1624-0.38732 0.77492v0.38746 0.38746l-0.38732 0.77493v0.38746 0.38746l-0.38731-0.38746v0.77492h-0.38732v-0.38746-0.38746l-0.38731 0.77492v0.38746h0.38731v0.38746h-0.38731l0.38731 0.38746-0.77463 0.77493-1.9366 1.9373-0.77463 0.38746v0.38746h-0.38732l-0.38731 0.38747h-0.38732l-0.38731 0.38746v0.38746h-0.38732v0.38746h-0.38732-0.38731l-0.77463 0.38746-0.38732 0.38746h-0.38732l-0.38731 0.38746-0.77463 0.38746h-0.38732l-0.77463 0.77493v0.38746h-0.38732-0.38731v0.38746 0.38746h-0.38732v0.38746h-0.38732v0.38746h-0.38731v0.38746l-0.77463 0.38747-0.77463 0.77492v0.38746l-0.38732 0.77492v0.77492l-0.38732 0.77493v0.38746l-0.38731 0.77492-0.38732 0.38746h-1.5493-0.38732l-0.77463 0.77492-0.38732-0.38746-0.38731 0.38746-1.162 0.38747h-0.77463l-0.38732 0.38746h-0.77463l-0.38732 1.9373v0.38746l0.77464 0.38746v-0.38746l1.5493 1.1624v0.38746 0.38746 0.38746 0.38746 1.1624l0.38732 0.38746h1.9366v0.38746h-0.38732l0.38732 0.38746v0.38746 0.38746h0.38731 0.38732v0.77492h0.77463v0.38747 0.38746h-0.77463v0.38746 0.38746h0.38731v0.38746h-0.38731-0.38732v0.38746l-0.38731 0.38746v0.77493 0.38746l-0.77464 0.77492h-0.38731v0.38746l0.38731 0.38746 0.77464 0.38746h0.38731 0.38732l0.38731-0.38746 0.38732-0.38746h0.38732l0.38731-0.38746v-0.38746h0.38732v-0.38746-0.38746l-0.38732-0.38747 1.162-0.38746 0.38732 0.77493v0.38746 0.38746 0.38746l0.38731 0.38746-0.38731 0.38746v0.38746 1.9373h0.77463v0.38746h-0.38732l1.162 0.77492v1.1624 0.38746 0.38746 0.38746l0.77463 0.77492h0.38732v0.38746l0.38731 0.77493v0.38746l0.38732 0.38746-0.38732 0.38746 0.38732 0.38746v0.38746 0.38746l-0.38732 0.38747-0.77463 0.38746-0.77463-0.38746-1.162-0.38747-0.77463-0.38746-0.38732-0.77492h-0.38731-0.38732l-0.38731-0.38746h-0.38732l-0.77463-0.38746-0.38732-0.38746h-0.38731-0.38732-1.162l-0.38731-0.38746h-0.38732l-0.77463 0.77492h-0.38732l-0.77463 0.38746h-0.38732l-0.38731 0.38746h-0.38732l-0.77463-0.38746-0.38731 0.38746h-0.38732l-0.38732 0.38746v0.38746h-0.38731l-0.38732 0.38746h-0.38731l-0.77464-0.77492h-1.1619-0.38732l-0.77463-0.77492-0.77463-0.38746h-0.38732-0.38732v0.77492l-0.38731 0.38746-0.38732 0.38746h-0.38731-0.38732l-0.38732-0.38746-0.38731-0.38746-0.38732 0.77492-0.38731 1.1624-0.77463 0.77492-0.38732 0.38746h0.38732l-0.38732 0.38746-0.38732 0.77492h-0.38731v0.38747l-0.38732 1.1624-0.38731 0.38746v0.38746h-0.38732-0.77463-0.38732v0.77492l-0.38731 0.38746h-0.38732-0.38732-0.38731v0.38747 0.38746l0.38731 0.38746v0.38746h-0.38731l-0.38732-0.38746-1.162 0.38746-0.38731-0.38746-0.77463 0.38746-0.38732-0.38746v0.38746 0.38746l0.38732 0.38746h-0.38732l0.38732 0.38746h0.38731 0.38732 0.77463l-0.38732 1.5498v0.38746h-0.77463v0.38746 0.38746h0.38732l0.38731 0.38746 0.77464 0.38746 0.38731 0.38747h0.38732v0.38746l0.38731 0.38746v0.38746h0.38732v0.38746h0.38732l0.38731-0.38746 0.38732-0.38746h0.38731l0.77464 0.77492 1.1619 0.38746v0.38746 0.38746 0.38747l0.38732 0.38746-0.77463 0.77492h-0.38732v0.38746l0.38732 0.38746 0.77463-0.38746h0.77463 0.77463 0.38732 0.77463 0.38732 0.38731l0.38732-0.38746 0.38731 0.38746 0.77464 0.38746 0.38731 0.38746 0.77463-0.77492h0.77464l0.77463 0.38746h0.38731v-0.38746l0.77464-0.38746 1.9366-0.77492v-0.38746h0.38731v-0.77493-0.77492l0.38732-0.77492v-0.38746l0.77463-1.1624 0.38731-0.38746 0.38732-0.38746v-0.38746l0.38732-0.38746h0.38731v0.38746l0.38732 0.38746 0.38731 0.38746h0.38732 0.77463 0.77463l0.38732-0.38746 0.38732-0.77492v-0.38746h0.38731 0.38732 0.38731l0.38732 0.38746v0.38746h0.38732 0.38731l0.38732 0.38746h0.38731l0.38732-0.38746v-0.38746l0.38732-0.38746h0.38731 0.77463 0.38732 0.38731l0.77464 0.38746 0.38731 0.38746h0.38732 0.77463l0.38732 0.38746v0.77492l1.1619 1.1624h0.38732 0.38732l0.38731 0.38746h0.38732v0.77492h0.38731l0.38732 0.38746h0.38732 0.38731l0.38732 0.38746 0.38731 0.38746v0.38747l0.38732 0.38746h0.38732 0.38731 0.77463 0.38732l1.162-0.38746h0.38731 1.162 0.77463 0.38732 0.38731v-0.38747-0.38746l-0.38731-0.38746 0.38731-0.38746h0.77464 0.38731l0.38732 0.38746 0.38731 0.38746v0.38746l0.38732 0.38747v0.38746l0.38732 0.38746h0.38731v0.38746l0.38732 0.38746h0.38731l0.38732-0.38746v-0.38746l0.38732-0.38746 0.77463-0.38746h0.38731l0.38732-0.77493v-0.38746h-0.38732v-0.77492h0.38732l-0.38732-0.38746h-0.38731v-0.38746-0.38746-0.38747l-0.77463-0.77492h-0.38732-0.38732v-0.38746l0.38732-0.38746h0.38732l-0.77464-0.38746 0.77464-1.1624h0.38731v0.38747h0.77463 0.38732l0.77463-0.38747h0.38732l0.38731-0.38746 0.38732-0.38746 0.38731 0.38746 0.77464-0.77492h0.38731l-0.38731-0.38746 0.38731-0.38746 0.38732-0.38746 1.162 1.1624h0.38731 0.38732l1.5493 0.38746h1.162l0.38732 0.38746v-0.77492-0.38746-0.38746-0.38746l-0.77464-0.38746h-0.38731v-0.38747-0.38746l-0.38732-0.77492-0.38731-0.38746h-0.77464-0.38731l0.38731-0.38746v-0.38746h0.38732l0.38732 0.38746 1.5493-0.77492 0.38732 0.38746h0.38731l0.38732 0.38746 0.77463 0.38746v0.38746h-0.77463l0.77463 0.77492 0.38731 0.38746 0.77464 0.38747h0.77463v-0.38747h0.77463l0.38732 0.38747h0.38731v-0.38747h0.38732v-0.38746l0.38731 0.38746 1.162 0.38747v0.38746l0.38732 0.77492v0.38746l0.77463-0.38746h0.77463 0.38732l0.38731 0.38746h0.38732l0.38732 0.38746v0.38746 0.38746h0.38731 0.38732 0.38731l0.77464 0.38747h0.38731l-0.38731-0.77493 0.38731 0.38746-0.38731-0.77492v-0.38746l0.38731-0.38746h-0.38731v-0.38746h-0.38732l-0.38732-0.38746v-0.38746-0.77493l0.77464 0.38746h0.38731l0.38732 0.38747h0.38731v0.38746h0.38732 0.38731l0.38732-0.38746 0.38732 0.77492h0.38731l0.38732 0.38746 0.38731-0.38746 1.162-0.38746v-0.38746-0.38747h0.38732l0.38731-0.38746h0.38732 0.38732l0.38731-0.38746v-0.38746h0.38732l0.38731-0.38746v0.38746h0.38732l0.38732-0.38746 0.77463-0.38746 1.9366-0.77492h0.38731 0.38732v-0.38746l0.77463-0.38747 0.77463-0.38746h0.38732l0.38731-0.38746v0.38746h0.38732 0.38732v0.38746l1.1619 1.1624 0.77464-0.38746v-0.38746h0.38731l0.38732-0.38747h0.38731v-0.38746l0.38732-0.38746h0.38732l0.77463-1.1624 0.38731-0.38746v-0.38746-0.38747-1.1624l0.77464-0.38746h0.77463l0.38731-0.77492-0.38731-0.38746v-0.77493-0.38746l-1.162-0.38746h0.38732l-2.3239-1.5498-0.38732-0.38747-0.38731-0.77492-1.9366-0.77492h-1.5493v-0.38746-0.77492-0.38747l0.38732-0.38746v-0.38746-0.38746h1.162l1.5493-0.77492v-0.38746-0.38746-0.38747h0.38732v-0.38746l0.38731-1.5498h-2.3239-0.38732l-1.5493-0.77492h-0.38732-0.77463l0.77463-1.1624v-1.1624-0.38746-0.38746l-1.162-0.77493h-0.38731l-0.38732 0.77493v-0.38747l-0.38731-0.38746-0.38732 0.38746-0.38731 0.38747v0.38746l-0.38732-0.38746-0.38732-0.38747 0.38732-0.38746-0.77463-0.38746h-0.38732l-1.5493 0.38746-1.9366-0.38746h-0.38732l-0.77463 0.38746-0.38732-0.38746h-0.38731v-0.38746l-0.38732-0.38746v-0.77492h-0.77463v-0.38746h-0.38732v-0.77493l-1.1619-0.77492-0.38732-0.77492v-0.38746-0.38746h-0.38731-0.77464-0.38731-0.38732v-0.38746l-0.38731 0.38746h-0.38732-0.77463l-0.38732 0.38746h-0.38731v0.77492h-0.77464v0.38746h-1.1619v-0.38746h-0.38732-0.38732-0.38731l-0.38732 0.38746-0.38731-0.38746h-0.38732-0.77463-0.38732-0.38731-0.38732v0.38746l-0.38732-0.38746h-0.38731-0.77463v-0.38746h-0.38732l-0.77463 0.38746v0.38746l0.38732 0.38746-0.38732 0.38746v-0.38746-0.38746h-0.38732-0.38731l-0.38732-0.77492v-0.38746l0.38732-0.38746h0.38731v-0.38746h-0.38731-0.38732-0.38731l-0.38732-0.38747v-0.38746-0.38746-0.38746l-0.38732-0.38746-0.38731-0.38746v-1.1624h-0.38732v-0.38746-0.38746h-0.38731-0.38732-0.38732v-1.1624-0.38746h-0.38731-0.38732v-0.38746h0.38732v-0.77493-0.77492-0.77492h0.38731l0.38732-0.38746h0.38732l-0.38732-0.38746h-0.38732l-0.38731-0.38747v-0.38746h0.38731v-0.38746h0.77464l0.77463-0.38746h0.38731v-0.38746h0.38732v-0.77492-0.38746-0.38747h-0.38732l-0.38731-0.38746v-0.77492-0.38746l0.38731-0.38746v-0.77492l-0.38731-0.38747-0.38732-0.38746v-0.77492l-0.38731-1.1624v-0.38746l-0.38732-0.38747-1.162-0.38746-0.38731-0.38746v-0.38746-0.38746l-0.77464-0.77492h-0.38731l-0.38732-0.38746-0.38731 0.38746h-0.38732-0.38732l-0.38731 0.38746-1.5493 1.5498-0.38732 0.38746-0.38732-0.38746v-0.38746l-0.38731 0.38746-0.38732 0.38746-0.77463 0.38747v-0.77493l-0.77463-1.1624-0.38732-0.77492-0.77463-1.1624-0.38732-0.38746zm-12.781 13.949-0.77463-0.38746 0.38731 0.38746h0.38732z"
).toNodes()
),
"Utrecht" to listOf(
PathParser().parsePathString(
"m87.466 105.88v0.38746h-0.38731v0.38746 0.38747l-0.77464-0.38747v0.38747l-0.77463 0.38746v0.38746h-0.38731-0.38732-0.38732l-0.77463-0.38746-0.38731 0.38746v0.38746l0.38731 0.38746-0.38731 0.38746-0.38732 0.38746v0.38746h-0.38731-0.38732v0.38747l-0.38732-0.38747h-0.38731-0.38732l-0.38731 0.38747-0.77464 0.38746v0.38746h-0.38731l-0.38732 0.38746h-0.38731v0.38746h-0.38732l-0.38732 0.38746h-0.38731-0.38732-0.38731v0.38746l0.38731 0.38746v0.77493 0.38746h0.38732v0.38746l0.38731 0.38746h0.38732v0.38746l0.38732 0.38746 0.38731 0.38746h0.77463l0.38732 0.38746 1.5493 1.1624-1.1619 0.38746v1.5498h-0.38732-0.38732-0.77463-0.38731v-0.38746h-0.77464l-0.77463 0.77493h0.38732l-0.38732 0.38746v0.38746h-0.38731-0.38732v0.38746l1.5493 0.77492 0.38732 0.38746h-0.38732v1.1624l0.38732 1.1624v0.38746h0.38732l-0.38732 0.38746h0.77463 1.5493l-0.77464 0.77493h-0.38731l-1.162 0.77492-0.38732 1.1624-0.38731 0.38746h-0.38732v0.38746l-0.38731 0.38747 0.38731 0.77492h0.38732l0.38731-0.38746h0.38732 0.38732 0.38731 0.38732l0.38731 1.1624h-0.38731l-1.5493 0.38746 0.38732 0.38746 0.38732 0.77493 0.38731 0.77492 0.38732 0.38746 0.77463 0.77492v0.38746l0.38732 0.38746v0.77493 0.38746h0.38731 0.77463 0.38732l0.38732-0.38746h0.38731v-0.38746h0.38732l-0.00974-0.41037 0.3 0.3 0.4 1.6 0.2-0.3 0.2-0.2 0.4 1.5 0.4 0.2v0.3l0.4 0.2v1l1.1-0.5v0.6l0.1 0.5v0.7l-0.1 0.3 0.1 0.3 1.4-0.7-0.1 0.9 0.3 0.9-0.05516 0.55959 1.162-0.38746 0.38732 0.38746h0.38731v-0.38746l-0.38731-0.38746v-0.38746-0.38747h0.38731 0.38732 0.38732l0.38731-0.38746v-0.77492h0.38732 0.77463 0.38732v-0.38746l0.38731-0.38746 0.38732-1.1624v-0.38747h0.38731l0.38732-0.77492 0.38732-0.38746h-0.38732l1.162-1.1624 0.38731-1.1624 0.38732-0.77492 0.77463 0.77492h0.38732 0.38731l0.77463-0.77492v-0.77492h0.38732 0.38732l0.77463 0.38746 0.77463 0.77492h0.38732 1.1619l0.77464 0.77492h0.38731l0.38732-0.38746h0.38731v-0.38746l0.38732-0.38746h0.38732l0.38731-0.38746 0.77463 0.38746h0.38732l0.38731-0.38746h0.38732l0.77463-0.38746h0.38732l0.38731-0.38746 0.38732-0.38746h0.38732l0.38731 0.38746h1.162 0.38732 0.38731l0.38732 0.38746 0.77463 0.38746h0.38732l0.38731 0.38746h0.38732 0.38731l0.38732 0.77492 0.77463 0.38746 1.162 0.38747 0.77463 0.38746 0.77463-0.38746 0.38732-0.38747v-0.38746-0.38746l-0.38732-0.38746 0.38732-0.38746-0.38732-0.38746v-0.38746l-0.38731-0.77493v-0.38746h-0.38732l-0.38732-0.38746-0.38731-0.38746v-0.38746-0.38746-0.38746-1.1624l-1.162-0.77492h0.38732v-0.38746h-0.77463v-1.9373-0.38746l0.38731-0.38746-0.38731-0.38746v-0.38746-0.38746-0.38746l-0.38732-0.77493-1.162 0.38746 0.38732 0.38747v0.38746 0.38746h-0.38732v0.38746l-0.38731 0.38746h-0.38732l-0.77463 0.77492h-0.38732-0.38731l-0.77464-0.38746-0.38731-0.38746v-0.38746h0.38731l0.77464-0.77492v-0.38746-0.77493l0.38731-0.38746v-0.38746h0.38732 0.38731v-0.38746h-0.38731v-0.38746-0.38746h0.77463v-0.38746-0.38747h-0.77463v-0.77492h-0.38732-0.38731v-0.38746-0.38746l-0.38732-0.38746h0.38732v-0.38746h-1.9366l-0.38732-0.38746v-1.1624-0.38746-0.38746-0.38746-0.38746l-1.5493-1.1624v0.38746l-0.77464-0.38746v-0.38746l0.38732-1.9373-0.38732-0.38746-0.38731-0.38747-0.38732-0.38746h-0.38731v-0.38746l-0.38732-0.38746h-0.38731-0.38732-0.38732l-0.38731-0.38746h-0.77463l-0.38732-0.38746h-1.5493l-0.77464-0.38746-1.1619 2.3248v0.38747 0.38746l-0.38732 0.77492-0.38732 1.1624-0.38731 0.77492v0.77493l-0.38732 0.38746v0.38746l-0.77463 1.5498h-0.77463-0.38732-0.38731l-2.3239-0.38746h-0.38731l-1.9366 0.77493-1.5493 0.38746v-1.5498h-0.38731v-0.77492-0.38746h-0.38732l-0.38732-0.38746h0.77464v-0.38746-0.38747-0.77492-0.77492h0.38731l0.77463-0.38746-0.77463-0.38746v-0.77492-0.38747h-0.38731v0.38747l-0.38732-0.38747-0.38732-1.1624v-0.38746h0.38732 0.38732v-0.38746h0.38731 0.38732v-0.38746h0.38731 0.38732l-0.38732-0.38746h-0.38731l-0.38732 0.38746h-0.38731l-0.38732-0.38746-0.38732 0.38746v-1.5498h-0.38731-0.38732z"
).toNodes()
),
"Noord-Holland" to listOf(
PathParser().parsePathString("m71.973 49.699-0.77464 0.38746-0.38731 0.38747h-0.38732v0.38746h-0.38731l-0.38732-0.38746v-0.38747-0.38746-0.38746h0.38732 0.38731 0.38732l1.162-0.38746h0.77463v0.38746l-0.77463 0.38746z")
.toNodes(),
PathParser().parsePathString(
"m73.909 50.474-0.77463 1.1624v0.38746 0.38746 0.77492l-0.38731 1.1624v1.1624 1.5498l-0.77463 2.3248-0.38732 2.3248-0.77463 2.3248v0.77492h-0.38732v0.77492l-0.77463 1.5498v0.77492l-0.77463 2.3248v0.38746 0.38746 0.38746 0.38746 1.1624l-0.38732 1.5498v0.77492 0.77493l-0.38731 1.5498v0.77492 0.38747 0.77492l-0.38732 0.38746v0.38746l-0.38732 2.7122-0.38731 3.4872-0.38732 1.9373-0.38731 0.77492-0.77464 1.5498-0.38731 1.1624 0.77463-0.38746h0.38732l0.77463-0.38747 0.38731 0.38747h-0.38731v0.38746h-0.77463l-0.38732 0.38746h0.77463v0.38746l-0.77463-0.38746h-0.38732v0.38746l-0.77463-0.38746v0.77492l0.38732 0.77492-0.38732 0.38746v0.77493l-0.38731 0.77492-0.38732 1.5498-0.38732 1.1624-0.77463 1.9373-1.5493 3.0997 2.7112 1.1624 1.162 0.38746v-0.77492l0.38731 0.38746 0.38732-0.
Path您可以通过创建具有以下内容的地图来获取路径的大小
结果
typealias Province = String
object Netherlands {
val PathParserMap = mapOf<Province, List<PathParser>>(
"Overijssel" to listOf(
PathParser().parsePathString(
"m144.01 59.386-1.162 0.77493-0.77463 0.77492h-1.162-0.38732l0.38732 0.77492v0.38746h-0.38732l-0.38731 0.38746-0.77463 0.38746v-0.77492l-1.162 0.38746-0.38732 0.38746v-0.38746h-0.38731l-0.38732-0.38746-0.38731-0.77492v-0.77492l-0.77464 0.38746v0.38746l-0.77463-0.38746v0.38746h-0.77463l-0.38732 0.38746v0.38746l-0.38731 0.38746v0.38746l-0.38732 0.38747h-0.38731v0.38746h-0.38732l-0.38732 0.38746h-0.38731-0.38732-0.38731l-0.38732-0.38746h-0.38732-0.38731v-0.38746h-0.38732-0.38731v-0.38747h-0.38732l-0.77463 0.77493 0.38731 0.77492 0.77464 0.77492v0.38746h0.77463 0.77463l0.38732 0.38746 1.1619 0.38747 0.38732 0.77492 0.38732 0.38746h0.38731l0.77463 0.77492 0.38732 1.1624 0.77463 1.5498v0.38746h0.38732l0.38731 0.38746v0.38746l0.38732 0.38747v0.38746 0.38746l-0.77463 0.38746-0.77463 0.77492v0.38746 0.38746h0.38731v-0.38746l0.77463 0.38746h0.38732l0.77463 0.38747 0.38732 0.38746 0.38731 0.38746h0.77463l0.38732 0.77492-0.38732 0.38746-1.1619 0.77492h-0.38732l-1.162 0.38747v0.38746l-0.77463 0.38746h-0.38731l-0.77464 0.38746-0.77463-0.77492-3.0985 0.77492-0.38731 0.38746v0.77492 0.38746 0.38747l0.38731 0.38746v0.38746l-1.5493-0.38746 0.38732 0.38746h0.38731 0.38732v0.38746l0.38731 0.38746v0.38746 0.38746l0.38732 0.38746 0.38732 0.38747v0.38746 0.38746l0.38731 0.38746v0.77492 0.77492l0.77463-0.38746 0.38732 0.38746 0.77463 1.1624 0.38732 0.77492 0.77463 1.1624v0.77493l0.77463-0.38747 0.77463-0.77492v0.38746l0.38732 0.38746 2.3239-2.3248h0.38732 0.38732l0.38731-0.38746 0.38732 0.38746h0.38731l0.77464 0.77492v0.38746 0.38746l0.38731 0.38746 1.162 0.38746 0.38732 0.38747v0.38746l0.38731 1.1624v0.77492l0.38732 0.38746 0.38731 0.38747v0.77492l-0.38731 0.38746v0.38746 0.77492l0.38731 0.38746h0.38732v0.38747 0.38746 0.77492h-0.38732v0.38746h-0.38731l-0.77463 0.38746h-0.77464v0.38746h-0.38731v0.38746l0.38731 0.38747h0.38732l0.38732 0.38746h-0.38732l-0.38732 0.38746h-0.38731v0.77492 0.77492 0.77493h-0.38732v0.38746h0.38732 0.38731v0.38746 1.1624h0.38732 0.38732 0.38731v0.38746 0.38746h0.38732v1.1624l0.77463 0.77492v0.38746 0.38746 0.38746l0.38732 0.38747h0.38731 0.38732 0.38731v0.38746h-0.38731l-0.38732 0.38746v0.38746l0.38732 0.77492h0.38731 0.38732v-0.38746l0.77463-0.38746h0.38732v0.38746h0.77463 0.38731l0.38732 0.38746v-0.38746h0.38732 0.38731 0.38732 0.77463 0.38732l0.38731 0.38746 0.38732-0.38746h0.38731 0.38732 0.38732v0.38746h1.1619v-0.38746h0.77464v-0.77492h0.38731l0.38732-0.38746h0.77463 0.38732l0.38731-0.38746v0.38746h0.38732 0.38731 0.77464 0.38731v0.38746 0.38746l0.38732 0.77492 1.1619 0.77492v0.77493h0.38732v0.38746h0.77463v0.77492l0.38732 0.38746v0.38746h0.38731l0.38732 0.38746 0.77463-0.38746h0.38732l1.9366 0.38746 1.5493-0.38746h0.38732l0.77463 0.38746-0.38732 0.38746 0.77464 0.77493v-0.38746l0.38731-0.38747 0.38732-0.38746 0.38731 0.38746v0.38747l0.38732-0.77493h0.38731l1.162 0.77493v0.38746 0.38746 1.1624l-0.77463 1.1624h0.77463 0.38732l1.5493 0.77492h0.38732 2.3239 3.0985 1.162l0.38731-0.38746 0.77464-0.77493v-0.38746l0.38731-1.9373h0.38732v-0.38746l1.162-0.77493v-0.38746l1.1619-0.38746h1.162l0.38732-0.77492v-0.38746l0.38731-0.38746v-0.38747l0.38732-0.38746v-0.38746-0.38746-0.38746l0.38732-0.38746 0.77463-0.38746 0.38731 0.38746h0.38732 0.38732 0.77463l1.1619-0.77492v-0.38746l-1.1619-1.5498-0.38732-0.38746v-0.77492h-0.38731v-0.38746-0.38747-0.38746-0.38746l0.38731-1.1624v-0.38746h0.38732v-0.38746h0.38731v-0.38747-0.38746l0.38732-0.77492v-0.38746l0.77463-1.1624v-1.9373l-0.77463-1.5498v-0.38746-0.38746h-0.38732-0.38731-0.38732l-0.38731-0.77492-0.38732-0.77492-0.77463-0.77493v-0.38746l-0.38732-0.77492v-0.77492l-0.38731-0.77492v-0.38747h-0.38732-0.38732l-0.38731 0.77493-0.38732 1.1624-0.77463 0.38746v0.38746h-0.38732l-1.9366-0.38746-0.77463-0.38746-1.162-0.38746h-0.77463l0.38732-0.77492h-0.77463-1.162-2.3239-0.77463l-0.38731-0.38746-1.5493-0.77493-0.38731-0.38746-0.77464-0.38746 0.38732-3.0997-0.77463-1.1624-0.77463-1.5498h0.38731l0.77463 0.38746h0.77464l0.38731-1.1624h0.77463l0.77464 0.38746 0.38731-0.38746-2.3239-1.9373v-0.77492l0.38731-1.5498v-0.38746l-0.38731-0.38747-0.38732-0.38746h-0.38732v-0.38746-0.38746-0.38746l0.38732-0.38746-0.38732-0.38746h-0.77463l-3.8732-1.9373v0.38746h-0.38731l-1.162 0.38746h-1.5493l-1.9366 1.9373 0.38731 2.3248v0.38746h-0.38731l-0.38732-0.38746h-0.38732-0.77463l-0.77463-0.77493v0.38747l-0.77463 0.77492-0.38732-0.38746h-0.38731v-0.38746-0.38747h-0.38732l-0.38731 0.38747v0.38746h-0.38732v-0.38746h-0.38732v0.38746h-0.38731-0.38732v0.38746h-0.38731l-0.38732-0.38746v-0.77493l-0.38732-0.38746v-0.38746h-0.38731v-0.38746-0.38746h-0.38732l-0.38731-0.38746h-0.38732l-0.38732-0.38746v-0.38746h-0.38731v-0.38747h0.38731v-0.38746h-0.38731-0.38732l-0.38731 0.38746h-0.38732-0.38732-0.38731v-0.38746h-0.38732v0.38746h-0.38731-0.38732v-0.38746h-0.38732l-0.38731-0.38746v-0.38746h-0.38732-0.38731-0.38732v-0.38746h-0.38732-0.38731-0.38732l-0.38731 0.38746v0.38746l-0.38732-0.38746v-0.38746l-0.38731 0.38746 0.38731 0.38746-1.162-0.38746 0.38732-0.38746v-0.38746l-0.77463-0.38746v-0.38746l-0.77463-1.1624v-0.38746-0.38746l-0.38732-0.77492-0.38732-0.77493-0.38731-0.77492v-0.38746h0.38731l0.38732-0.38746 1.162-0.38746 0.38731-0.38746h0.38732v-0.38746l0.77463-0.77493 0.38732-0.38746 0.38731-0.77492h-0.38731l-0.38732-0.77492-3.0985-3.0997v-0.38746l-0.38731-0.77493zm2.7112 52.695v0.38746 0.38746l0.38732-0.38746-0.38732-0.38746z"
)
),
// Rest of the provinces
)
val PathNodeMap: Map<Province, List<List<PathNode>>> =
PathParserMap.mapValues { entry: Map.Entry<Province, List<PathParser>> ->
entry.value.map {
it.toNodes().toList()
}
}
val PathMap: Map<Province, List<Path>> =
PathParserMap.mapValues { entry: Map.Entry<Province, List<PathParser>> ->
entry.value.map {
it.toPath()
}
}
}
Run Code Online (Sandbox Code Playgroud)
您可以使用以下命令获取任何路径的边界中心
val pathList = Netherlands.PathMap[province]
val pathForSize = Path()
pathList?.forEach {
pathForSize.addPath(it)
}
val center = pathForSize.getBounds().center
Run Code Online (Sandbox Code Playgroud)
全面实施
@Composable
fun Netherlands(modifier: Modifier = Modifier, selecetedIndex: Int) {
val vectorPainter = rememberVectorPainter(
defaultWidth = 200.dp,
defaultHeight = 236.dp,
viewportHeight = 236f,
viewportWidth = 200f,
autoMirror = false
) { _, _ ->
val duration = 3000
val transition = rememberInfiniteTransition(label = "transition")
val scale by transition.animateFloat(
initialValue = 1.0f,
targetValue = 1.4f,
animationSpec = infiniteRepeatable(
tween(duration, easing = EaseInOut),
repeatMode = RepeatMode.Reverse
), label = "scaleTransition"
)
var index = 0
for (entry in Netherlands.PathNodeMap) {
val (province, paths) = entry
val pathList = Netherlands.PathMap[province]
val pathForSize = Path()
pathList?.forEach {
pathForSize.addPath(it)
}
val center = pathForSize.getBounds().center
Group(
name = province,
scaleX = if (index == selecetedIndex) scale else 1.0f,
scaleY = if (index == selecetedIndex) scale else 1.0f,
pivotX = center.x,
pivotY = center.y
) {
for (path in paths) {
Path(
stroke = SolidColor(Color.White),
pathData = path,
fill = SolidColor(if (index == selecetedIndex) Color.Red else Color.Black),
)
}
}
index++
}
}
Image(
modifier = modifier,
painter = vectorPainter,
contentDescription = null
)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
271 次 |
| 最近记录: |