int main(int argc, char **argv){
  awake_the_weaver(); // Initializing Weaver API
  
  camera *cam = new_camera(0.0, 0.0, 100.0, 100.0);
  circle *star   = new_circle(50.0, 50.0, 20.0);
  circle *planet = new_circle(90.0, 90.0,  5.0);
  rectangle *trash = new_rectangle(75.0, 50.0, 1.25, 2.5);
  rectangle *ufo   = new_rectangle(25.0, 50.0, 1.5,  1.5);
  film_fullcircle(cam, star, YELLOW);
  film_fullcircle(cam, planet, BLUE);
  film_rectangle(cam, trash, GREEN);
  film_fullrectangle(cam, ufo, WHITE);

  int camera_moved = 0;

  // Main loop
  for(;;){
    get_input();
    if(keyboard[ESC]){
      break;
    }
	if(keyboard[UP] || keyboard[DOWN] || keyboard[LEFT] || keyboard[RIGHT] ||
			keyboard[MINUS] || keyboard[PLUS] || keyboard[ENTER]){
		film_fullcircle(cam, star, BLACK);
		film_fullcircle(cam, planet, BLACK);
		film_rectangle(cam, trash, BLACK);
		film_fullrectangle(cam, ufo, BLACK);
		camera_moved = 1;
	}
	if(keyboard[UP])
		cam -> y -= 1.0;
	if(keyboard[DOWN])
		cam -> y += 1.0;
	if(keyboard[LEFT])
		cam -> x -= 1.0;
	if(keyboard[RIGHT])
		cam -> x += 1.0;
	if(keyboard[PLUS])
		zoom_camera(cam, 1.01);
	if(keyboard[MINUS])
		zoom_camera(cam, 0.99);
	if(keyboard[ENTER])
		center_camera(cam, 50.0, 50.0);

	film_fullcircle(cam, planet, BLACK);
	rotate_circle(planet, 50.0, 50.0, 0.01);
	film_fullcircle(cam, planet, BLUE);

	if(camera_moved){
		film_fullcircle(cam, star, YELLOW);
		film_rectangle(cam, trash, GREEN);
		film_fullrectangle(cam, ufo, WHITE);
		camera_moved = 0;
	}

    weaver_rest(10000000);
  }
  may_the_weaver_sleep();
  return 0;
}
Exemple #2
0
/**
 * Locates the positions of the corners of a component
 * 
 * @param   child  The child, to the component using the layout manager, of interest
 * @return         The rectangle the child is confound in
 */
static rectangle_t locate(__this__, itk_component* child)
{
  if (child->visible)
    {
      size2_t c = CONTAINER(this)->size;
      position_t x = LEFT(this), y = TOP(this);
      dimension_t w = c.width - RIGHT(this);
      dimension_t h = c.height - BOTTOM(this);
      if ((w | h) < 0)
	{
	  w = c.width;
	  h = c.height;
	  x = y = 0;
	}
      return new_rectangle(x, y, w, h);
    }
  else
    {
      rectangle_t rc;
      rc.defined = false;
      return rc;
    }
}