fixed first start for theme video
[livewp] / applet / src / livewp-rules.c
index 6b3ff2e..7658e6e 100644 (file)
@@ -49,18 +49,23 @@ void get_localtime(int * year, int * month, int * day, int * hour, int * min, in
 
 void get_coord(double * lat, double * lon)
 {
+    /* coordinates St.-Petersburg */
     *lat = 59.883333;
     *lon = 30.25;
+
+    /* coordinates Vitebsk */
+    //*lat = 55.166666;
+    //*lon = 30.133333;
+
+
 }
 
 double
 get_max_sun_alt(double lon, double lat, int year, int month, int day, int zone)
 {
     int h1, m1, h2, m2, h, m;
-    time_t t1, t2, t;
-    struct tm tm1, tm2;
+    struct tm;
     double alt, hour1, hour2, hh, x;
-    int hour, min;
 
     sun_rise_set(lon, lat,
                  year, month, day, 
@@ -122,19 +127,42 @@ int get_daytime()
     if (alt > -7 && alt < 7 && azm < 50) return TIME_SUNRISE;
     if (alt > -7 && alt < 7 && azm > 50) return TIME_SUNSET;
     if (alt >= 7) return TIME_DAY;
-    
+    return TIME_DAY;
 }
+
 int get_moon_phase()
 { 
     int year, month, day, hour, min, zone;
     double phase;
     get_localtime(&year, &month, &day, &hour, &min, &zone);
     phase = moon_phase(year, month, day) * 100;
-    printf("ph = %f\n", phase);
+    /* printf("ph = %f\n", phase); */
     if (phase <= 3 || phase >=97) return MOON_NONE;
     if (phase > 5 && phase <= 25) return MOON_GROWS;
     if (phase > 25 && phase <= 45) return MOON_GROWSHALF;
     if (phase > 45 && phase <= 55) return MOON_FULL;
     if (phase > 55 && phase <= 75) return MOON_DECREASHALF;
     if (phase > 75 && phase < 97) return MOON_DECREAS;
+    return MOON_NONE;
+
 }
+
+gint 
+fast_rnd(gint max)
+{
+    guint offset = 12923; 
+    guint multiplier = 4079; 
+    static guint seed = 123;
+
+    seed = seed * multiplier + offset;
+    return (gint)(seed % max);
+}
+void 
+get_sun_screen_pos(double alt, double azm, gint * x, gint * y)
+{
+    gint y0 = 365;// - уровень горизонта
+    *x = (int)(azm * 800) - 64;
+    *y = (int)((1 - alt) * y0) - 64;
+    //fprintf(stderr, "sun pos alt=%f azm=%f x=%d y=%d\n", alt, azm, *x, *y);
+}
+