Guest User

Sun position bar on Glance face

a guest
Sep 1st, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. Assuming the bar is drawn with a line on an axis between 0 and 1.0, an empty bar would be (0,0), a full bar would be (0,1.0), left half would be (0,0.5), and right half would be (0.5,1.0)
  2.  
  3. Right now, I'm assuming the sun bar is calculated something like this:
  4.  
  5. get_sun_line(time_now, time_dawn, time_dusk) {
  6. if (time_now < time_dawn) or (time_now > time_dusk) {
  7. return (0,0)
  8. }
  9.  
  10. minutes_total := time_dusk - time_dawn
  11. minutes_now := time_now - time_dawn
  12. x := minutes_now / minutes_total
  13.  
  14. return (0, x)
  15. }
  16.  
  17. In other words, near dawn (dim light) the bar is small, at noon (brightest light) it is half, and at dusk (dim light) it is full. But isn't it more natural to have noon be full bar, and have the bar small near dawn and dusk (but on opposite sides)?
  18.  
  19. So, something like this?
  20.  
  21. get_sun_line(time_now, time_dawn, time_dusk) {
  22. if (time_now < time_dawn) or (time_now > time_dusk) {
  23. return (0,0)
  24. }
  25.  
  26. solar_noon := median(time_dawn, time_dusk)
  27.  
  28. if (time_now <= solar_noon) {
  29. x_left := 0
  30. } else {
  31. x_left := (time_now - solar_noon) / (time_dusk - solar_noon)
  32. }
  33.  
  34. if (time_now >= solar_noon) {
  35. x_right := 1.0
  36. } else {
  37. x_right := (time_now - time_dawn) / (solar_noon - time_dawn)
  38. }
  39.  
  40. return (x_left, x_right)
  41. }
  42.  
  43. This would also more closely resemble the encoding of the moon bar, no?
  44.  
Advertisement
Add Comment
Please, Sign In to add comment