diff --git a/build.gradle.kts b/build.gradle.kts index d2dfd7e..5c1d24e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ val ktorVersion by extra("2.0.3") allprojects { group = "center.sciprog" - version = "0.1.0-dev-3" + version = "0.1.0-dev-4" } ksciencePublish{ diff --git a/demo/maps/src/jvmMain/kotlin/Main.kt b/demo/maps/src/jvmMain/kotlin/Main.kt index fb3debf..989a2c3 100644 --- a/demo/maps/src/jvmMain/kotlin/Main.kt +++ b/demo/maps/src/jvmMain/kotlin/Main.kt @@ -24,6 +24,7 @@ import kotlin.math.PI import kotlin.random.Random import center.sciprog.maps.coordinates.kilometers import center.sciprog.maps.coordinates.radians +import center.sciprog.maps.coordinates.Angle private fun GeodeticMapCoordinates.toShortString(): String = "${(latitude.degrees.value).toString().take(6)}:${(longitude.degrees.value).toString().take(6)}" @@ -92,7 +93,7 @@ fun App() { drawLine(start = Offset(-10f, 10f), end = Offset(10f, -10f), color = Color.Red) } - arc(pointOne, 10.0.kilometers, 0f.radians, PI.radians) + arc(pointOne, 10.0.kilometers, (PI/4).radians, -Angle.pi/2) line(pointOne, pointTwo, id = "line") text(pointOne, "Home", font = { size = 32f }) diff --git a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt index 5562473..b4a359b 100644 --- a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt +++ b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt @@ -108,10 +108,14 @@ public class MapLineFeature( override fun getBoundingBox(zoom: Double): GmcRectangle = GmcRectangle(a, b) } +/** + * @param startAngle the angle from parallel downwards for the start of the arc + * @param arcLength arc length + */ public class MapArcFeature( public val oval: GmcRectangle, public val startAngle: Angle, - public val endAngle: Angle, + public val arcLength: Angle, override val zoomRange: IntRange = defaultZoomRange, public val color: Color = Color.Red, ) : MapFeature { diff --git a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeatureBuilder.kt b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeatureBuilder.kt index 346ba93..433e4f4 100644 --- a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeatureBuilder.kt +++ b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeatureBuilder.kt @@ -134,31 +134,31 @@ public fun MapFeatureBuilder.line( public fun MapFeatureBuilder.arc( oval: GmcRectangle, startAngle: Angle, - endAngle: Angle, + arcLength: Angle, zoomRange: IntRange = defaultZoomRange, color: Color = Color.Red, id: FeatureId? = null, ): FeatureId = addFeature( id, - MapArcFeature(oval, startAngle, endAngle, zoomRange, color) + MapArcFeature(oval, startAngle, arcLength, zoomRange, color) ) public fun MapFeatureBuilder.arc( center: Pair, radius: Distance, startAngle: Angle, - endAngle: Angle, + arcLength: Angle, zoomRange: IntRange = defaultZoomRange, color: Color = Color.Red, id: FeatureId? = null, ): FeatureId = addFeature( id, MapArcFeature( - GmcRectangle.square(center.toCoordinates(), radius, radius), - startAngle, - endAngle, - zoomRange, - color + oval = GmcRectangle.square(center.toCoordinates(), radius, radius), + startAngle = startAngle, + arcLength = arcLength, + zoomRange = zoomRange, + color = color ) ) diff --git a/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt b/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt index 0416684..330a96d 100644 --- a/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt +++ b/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt @@ -254,7 +254,7 @@ public actual fun MapView( addArcRad( Rect(topLeft, bottomRight), feature.startAngle.radians.value.toFloat(), - (feature.endAngle - feature.startAngle).radians.value.toFloat() + feature.arcLength.radians.value.toFloat() ) }