Skip to content

Commit

Permalink
Use moon tilt on navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Oct 25, 2024
1 parent adc9dbe commit cc605da
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ class LinearCompassView : BaseCompassView {
opacity((255 * reference.opacity).toInt())
val bitmap = getBitmap(reference.drawableId, sizeDp)
imageMode(ImageMode.Corner)
image(
bitmap,
x - sizeDp / 2f,
(iconSize - sizeDp) * 0.6f
)
push()
translate(x - sizeDp / 2f, (iconSize - sizeDp) * 0.6f)
rotate(reference.rotation, bitmap.width / 2f, bitmap.height / 2f)
image(bitmap, 0f, 0f)
pop()
noTint()
opacity(255)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface IMappableReferencePoint : Identifiable {
val tint: Int?
val opacity: Float
val bearing: Bearing
val rotation: Float
}

data class MappableReferencePoint(
Expand All @@ -27,6 +28,7 @@ data class MappableReferencePoint(
override val bearing: Bearing,
override val tint: Int? = null,
override val opacity: Float = 1f,
override val rotation: Float = 0f
) : IMappableReferencePoint


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ class RadarCompassView : BaseCompassView, IMapView {
push()
rotate(reference.bearing.value)
val bitmap = getBitmap(reference.drawableId, sizeDp)
image(bitmap, width / 2f - sizeDp / 2f, (iconSize - sizeDp) * 0.6f)
push()
translate(width / 2f - sizeDp / 2f, (iconSize - sizeDp) * 0.6f)
rotate(reference.rotation, bitmap.width / 2f, bitmap.height / 2f)
image(bitmap, 0f, 0f)
pop()
pop()
noTint()
opacity(255)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ class RoundCompassView : BaseCompassView {
rotate(reference.bearing.value)
val bitmap = getBitmap(reference.drawableId, sizeDp)
imageMode(ImageMode.Corner)
image(bitmap, width / 2f - sizeDp / 2f, (iconSize - sizeDp) * 0.6f)
push()
translate(width / 2f - sizeDp / 2f, (iconSize - sizeDp) * 0.6f)
rotate(reference.rotation, bitmap.width / 2f, bitmap.height / 2f)
image(bitmap, 0f, 0f)
pop()
pop()
noTint()
opacity(255)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ data class NavAstronomyData(
val moonBearing: Bearing,
val isSunUp: Boolean,
val isMoonUp: Boolean,
val moonPhase: MoonTruePhase
val moonPhase: MoonTruePhase,
val moonTilt: Float
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class NavAstronomyDataCommand(private val gps: IGPS) : CoroutineValueCommand<Nav
astronomy.getMoonAzimuth(gps.location),
astronomy.isSunUp(gps.location),
astronomy.isMoonUp(gps.location),
astronomy.getMoonPhase(LocalDate.now()).phase
astronomy.getMoonPhase(LocalDate.now()).phase,
astronomy.getMoonTilt(gps.location)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ class UpdateAstronomyLayerCommand(
)
}


if (astro.isMoonUp) {
markers.add(
MappableReferencePoint(
2,
MoonPhaseImageMapper().getPhaseImage(astro.moonPhase),
fromTrueNorth(astro.moonBearing)
fromTrueNorth(astro.moonBearing),
rotation = astro.moonTilt
)
)
} else if (showWhenDown) {
Expand All @@ -58,7 +60,8 @@ class UpdateAstronomyLayerCommand(
2,
MoonPhaseImageMapper().getPhaseImage(astro.moonPhase),
fromTrueNorth(astro.moonBearing),
opacity = 0.5f
opacity = 0.5f,
rotation = astro.moonTilt
)
)
}
Expand Down

0 comments on commit cc605da

Please sign in to comment.