Day and Night |
Note that not every phone makes it's light sensor available to apps. You can check this with the light.kt mini-app.
The idea is to show an image that changes depending on the current light sensor input. In a bright environment, is shows a scene in bright daylight. In a dark environment, it shows a night time scene.
Here are two images from a simple implementation:
You can improve this simple version in many ways: The color of the sun changes when it sets (from yellow to orange to deep red). Place something in the empty space on the right side, such as a house, a tree, or an animal. The animal could walk around during bright light, and go to sleep in the night.
To get you started, here are the colors I used for day and night scenes (and I'm interpolating in between):
val sky1 = Color(152, 255, 255) val sky0 = Color(7, 22, 124) val grass1 = Color(26, 214, 13) val grass0 = Color(11, 88, 5) val sun1 = Color(251, 253, 78) val moon1 = Color(230, 225, 202)
Day and Night |