Skip to content

Commit

Permalink
Draw moon icon
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Nov 4, 2023
1 parent 066bdeb commit 1f023bc
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.camera.view.PreviewView
import androidx.core.graphics.drawable.toBitmapOrNull
import com.kylecorry.andromeda.core.coroutines.onDefault
import com.kylecorry.andromeda.core.system.Resources
import com.kylecorry.andromeda.core.time.CoroutineTimer
import com.kylecorry.andromeda.fragments.BoundFragment
import com.kylecorry.andromeda.fragments.inBackground
Expand All @@ -18,6 +20,7 @@ import com.kylecorry.sol.units.Bearing
import com.kylecorry.sol.units.Distance
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.astronomy.domain.AstronomyService
import com.kylecorry.trail_sense.astronomy.ui.MoonPhaseImageMapper
import com.kylecorry.trail_sense.databinding.FragmentAugmentedRealityBinding
import com.kylecorry.trail_sense.navigation.beacons.domain.Beacon
import com.kylecorry.trail_sense.navigation.beacons.infrastructure.persistence.BeaconRepo
Expand Down Expand Up @@ -265,15 +268,21 @@ class AugmentedRealityFragment : BoundFragment<FragmentAugmentedRealityBinding>(
val sunAltitude = astro.getSunAltitude(location)
val sunAzimuth = astro.getSunAzimuth(location).value

val phase = astro.getMoonPhase(LocalDate.now())
val moonIconId = MoonPhaseImageMapper().getPhaseImage(phase.phase)
val moonIcon = Resources.drawable(requireContext(), moonIconId)
val moonImageSize = Resources.dp(requireContext(), 24f).toInt()
val moonBitmap = moonIcon?.toBitmapOrNull(moonImageSize, moonImageSize)

val moon = ARMarkerImpl.horizon(
AugmentedRealityView.HorizonCoordinate(
moonAzimuth,
moonAltitude,
true
),
2f,
// TODO: Use moon icon
CircleCanvasObject(Color.WHITE),
moonBitmap?.let { BitmapCanvasObject(moonBitmap) }
?: CircleCanvasObject(Color.WHITE),
onFocusedFn = {
// TODO: Display moon phase
binding.arView.focusText = getString(R.string.moon)
Expand Down

0 comments on commit 1f023bc

Please sign in to comment.