added moon moving
authortanya <tanya@moshkanov.oblgaz>
Sat, 24 Apr 2010 23:53:12 +0000 (02:53 +0300)
committertanya <tanya@moshkanov.oblgaz>
Sat, 24 Apr 2010 23:53:12 +0000 (02:53 +0300)
applet/src/livewp-home-widget.c

index d4ff7fd..96a3077 100644 (file)
@@ -261,6 +261,25 @@ change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
 {
     gint phase;
     char *newfile;
+    gint x0 = 150,
+         x1 = 650, 
+         x, y,
+         y0=150, y1 = 150, x2=400, y2=30;
+    double a, b, c;
+    struct timeval tvb;     
+    suseconds_t ms;
+    long sec;
+    double t;
+#if 0
+    a = (double)(y2 - (double)(x2*(y1-y0) + x1*y0 - x0*y1)/(x1-x0))/(x2*(x2-x0-x1)+x0*x1);
+    b = (double)(y1-y0)/(x1-x0) - (double)a*(x0+x1);
+    c = (double)(x1*y0 - x0*y1)/(x1-x0) + (double)a*x0*x1;
+    fprintf(stderr, "a=%f, b=%f, c=%f\n", a, b, c);
+#endif
+    gettimeofday(&tvb, NULL);
+    
+    ms = tvb.tv_usec;
+    sec = tvb.tv_sec;
 
     if (actor){
         if (scene.daytime == TIME_NIGHT){
@@ -271,14 +290,26 @@ change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
                 if (actor->filename)
                     g_free(actor->filename);
                 actor->filename = newfile;
+                actor->time_start_animation = sec - fast_rnd(60 * 60);
+                actor->duration_animation = 1 * 60 * 60;
                 create_hildon_actor(actor, desktop_plugin);
 
             }
-            //actor->x = 400;
-            //actor->y = 10;
-           // actor_set_position_full(actor->widget, x, y, actor->z);
-            //probability_sun(actor);
-            //fprintf(stderr, "after change sun %d\n", actor->time_start_animation);
+            t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
+            if (t <= 1)
+                x = path_line(x0, x1, t);
+            else 
+                x = path_line(x1, x0, t-1);
+            //y = path_line(y0, y1, t);
+            y = 0.001920*x*x - 1.536*x + 337.2;
+            //y = a*x*x + b*x + c;
+
+            actor_set_position_full(actor->widget, x, y, actor->z);
+
+            if (t>=2){
+                actor->time_start_animation = sec;
+            }
+
          }else if (actor->visible){
             actor->visible = FALSE;
             fprintf(stderr, "destroy moon \n");
@@ -486,7 +517,6 @@ change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
             g_free(actor->filename);
         actor->filename = newfile;
          
-
         create_hildon_actor(actor, desktop_plugin);
     }
     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;