Fixed quick scaling
This commit is contained in:
parent
be85e92397
commit
47cd68fcfe
1 changed files with 16 additions and 10 deletions
|
|
@ -21,6 +21,7 @@ import androidx.compose.ui.text.drawText
|
||||||
import androidx.compose.ui.text.rememberTextMeasurer
|
import androidx.compose.ui.text.rememberTextMeasurer
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.withStyle
|
import androidx.compose.ui.text.withStyle
|
||||||
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MapCanvas(
|
fun MapCanvas(
|
||||||
|
|
@ -48,17 +49,22 @@ fun MapCanvas(
|
||||||
)
|
)
|
||||||
val oldLevel = tileContainer.getLevel()
|
val oldLevel = tileContainer.getLevel()
|
||||||
val level = scale.floatValue.toInt()
|
val level = scale.floatValue.toInt()
|
||||||
|
val levelDiff = level - oldLevel
|
||||||
|
|
||||||
if (oldLevel > level) {
|
if (levelDiff < 0) {
|
||||||
offsetX.floatValue -= size.width / 2F + TILE_SIZE
|
repeat (levelDiff.absoluteValue) {
|
||||||
offsetY.floatValue -= size.height / 2F + TILE_SIZE
|
offsetX.floatValue -= size.width / 2F + TILE_SIZE
|
||||||
offsetX.floatValue /= 2F
|
offsetY.floatValue -= size.height / 2F + TILE_SIZE
|
||||||
offsetY.floatValue /= 2F
|
offsetX.floatValue /= 2F
|
||||||
} else if (oldLevel < level) {
|
offsetY.floatValue /= 2F
|
||||||
offsetX.floatValue *= 2F
|
}
|
||||||
offsetY.floatValue *= 2F
|
} else if (levelDiff > 0) {
|
||||||
offsetX.floatValue += size.width / 2F + TILE_SIZE
|
repeat (levelDiff) {
|
||||||
offsetY.floatValue += size.height / 2F + TILE_SIZE
|
offsetX.floatValue *= 2F
|
||||||
|
offsetY.floatValue *= 2F
|
||||||
|
offsetX.floatValue += size.width / 2F + TILE_SIZE
|
||||||
|
offsetY.floatValue += size.height / 2F + TILE_SIZE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val tileOffsetX = (offsetX.floatValue / TILE_SIZE).toInt()
|
val tileOffsetX = (offsetX.floatValue / TILE_SIZE).toInt()
|
||||||
val tileOffsetY = (offsetY.floatValue / TILE_SIZE).toInt()
|
val tileOffsetY = (offsetY.floatValue / TILE_SIZE).toInt()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue