Android Question graph showing the progress between two times


Licensed User
Well, the math behind it is simple enough.

Dim X1 As Float = 123 'left
Dim X2 As Float = 987 'right
Dim Y1 As Float = 135 'top
Dim Y2 As Float = 357 'bottom

Dim T1 As Float = 5 * 60 + 27 'eg time-of-day in minutes
Dim T2 As Float = 19 * 60 + 41

and then you just need something to calculate the X and Y of the sun position or path at time T

Dim P As Float = (T - T1) / (T2 - T1) 'P is proportion 0..half..1 of T within time range T1..midday..T2
Dim X As Float = X1 + P * (X2 - X1)
Dim Y As Float = Y2 + SinD(P * 180) * (Y1 - Y2) 'shape good enough; if you really need a circular arc, it can be done with a bit more math

so all you have to do now is put coloured pixels at those locations... how hard could that be?!?!

A starting point might be to make a small square panel to represent your sun (background = yellow) and set the corner radius sufficiently large to turn the square into a circle (or somewhere in between, to make your app more memorable ;-) You can then move the sun about by changing the panel's Left and Top (aka X and Y) properties.


Licensed User
that's great. Thank you very much for your time.
Just noticed from screenshots that there is a bug in the time-formatting routine: the hours must be getting rounded off to the nearest integer.

Solution is to Floor the Time / 60 divisions eg:

NumberFormat2(Floor(SunriseTime / 60), 1, 0, 0, False)

so that there is no fractional part for NumberFormat2 to round off.