Exemplo n.º 1
0
static Bool
loading_initial_image (ModeInfo *mi)
{
  photopile_state *ss = &sss[MI_SCREEN(mi)];

  if (ss->frames[ss->nframe].loaded_p)
    {
      /* The initial image has been fully loaded, start fading it in. */
      int i;

      for (i = 0; i < ss->nframe; ++i)
        {
          ss->frames[i].pos[3].x = MI_WIDTH(mi) * 0.5;
          ss->frames[i].pos[3].y = MI_HEIGHT(mi) * 0.5;
          ss->frames[i].pos[3].angle = 0.0;
        }
      set_new_positions(ss);

      ss->mode = SHUFFLE;
      ss->mode_tick = fade_ticks / speed;
    }
  else
    {
      loading_msg(mi);
    }

  return (ss->mode == EARLY);
}
Exemplo n.º 2
0
static Bool
load_initial_images (ModeInfo *mi)
{
  carousel_state *ss = &sss[MI_SCREEN(mi)];
  int i;
  Bool all_loaded_p = True;
  for (i = 0; i < ss->nframes; i++)
    if (! ss->frames[i]->loaded_p)
      all_loaded_p = False;

  if (all_loaded_p)
    {
      if (ss->nframes < MI_COUNT (mi))
        {
          /* The frames currently on the list are fully loaded.
             Start the next one loading.  (We run the image loader
             asynchronously, but we load them one at a time.)
           */
          load_image (mi, alloc_frame (mi));
        }
      else
        {
          /* The first batch of images are now all loaded!
             Stagger the expire times so that they don't all drop out at once.
           */
          time_t now = time((time_t *) 0);
          int i;

          for (i = 0; i < ss->nframes; i++)
            {
              image_frame *frame = ss->frames[i];
              frame->r = 1.0;
              frame->theta = i * 360.0 / ss->nframes;
              frame->expires = now + (duration * (i + 1));
              frame->mode = NORMAL;
            }

          /* Instead of always going clockwise, shuffle the expire times
             of the frames so that they drop out in a random order.
          */
          for (i = 0; i < ss->nframes; i++)
            {
              image_frame *frame1 = ss->frames[i];
              image_frame *frame2 = ss->frames[random() % ss->nframes];
              time_t swap = frame1->expires;
              frame1->expires = frame2->expires;
              frame2->expires = swap;
            }

          ss->awaiting_first_images_p = False;
        }
    }
      
  loading_msg (mi, ss->nframes-1);

  return !ss->awaiting_first_images_p;
}