0.3.0 #23

Open
altavir wants to merge 40 commits from dev into main
3 changed files with 17 additions and 4 deletions
Showing only changes of commit 2bc595d97d - Show all commits

View File

@ -157,6 +157,14 @@ fun doubleObstacle() {
} }
} }
@Composable
@Preview
fun singleElement() {
SchemeView {
points(listOf(XY(1f,1f)))
}
}
@Composable @Composable
@Preview @Preview
@ -165,6 +173,7 @@ fun playground() {
"Close starting points", "Close starting points",
"Single obstacle", "Single obstacle",
"Two obstacles", "Two obstacles",
"Single element"
) )
var currentExample by remember { mutableStateOf(examples.first()) } var currentExample by remember { mutableStateOf(examples.first()) }
@ -182,6 +191,7 @@ fun playground() {
examples[0] -> closePoints() examples[0] -> closePoints()
examples[1] -> singleObstacle() examples[1] -> singleObstacle()
examples[2] -> doubleObstacle() examples[2] -> doubleObstacle()
examples[3] -> singleElement()
} }
} }
} }

View File

@ -63,7 +63,7 @@ public class MapViewScope internal constructor(
canvasSize.width.value / rectangle.longitudeDelta.radians, canvasSize.width.value / rectangle.longitudeDelta.radians,
canvasSize.height.value / rectangle.latitudeDelta.radians canvasSize.height.value / rectangle.latitudeDelta.radians
) * 2 * PI / mapTileProvider.tileSize ) * 2 * PI / mapTileProvider.tileSize
) ).coerceIn(0.0..22.0)
return space.ViewPoint(rectangle.center, zoom.toFloat()) return space.ViewPoint(rectangle.center, zoom.toFloat())
} }

View File

@ -26,12 +26,15 @@ public class XYViewScope(
) )
override fun computeViewPoint(rectangle: Rectangle<XY>): ViewPoint<XY> { override fun computeViewPoint(rectangle: Rectangle<XY>): ViewPoint<XY> {
val scale = min( val scale: Float = min(
canvasSize.width.value / rectangle.width, canvasSize.width.value / rectangle.width,
canvasSize.height.value / rectangle.height canvasSize.height.value / rectangle.height
) )
return if(scale.isInfinite()){
return XYViewPoint(rectangle.center, scale) XYViewPoint(rectangle.center, 1f)
} else {
XYViewPoint(rectangle.center, scale)
}
} }
override fun ViewPoint<XY>.moveBy(x: Dp, y: Dp): ViewPoint<XY> { override fun ViewPoint<XY>.moveBy(x: Dp, y: Dp): ViewPoint<XY> {