コード例 #1
0
ファイル: graphics.c プロジェクト: 4nakin/freeciv-android
/***************************************************************************
 ...
***************************************************************************/
void create_overlay_unit(struct canvas *pcanvas, struct unit_type *punittype)
{
  int x1, x2, y1, y2;
  int width, height;
  struct sprite *sprite = get_unittype_sprite(tileset, punittype);

  sprite_get_bounding_box(sprite, &x1, &y1, &x2, &y2);
  if (pcanvas->type == CANVAS_PIXBUF) {
    width = gdk_pixbuf_get_width(pcanvas->v.pixbuf);
    height = gdk_pixbuf_get_height(pcanvas->v.pixbuf);
    gdk_pixbuf_fill(pcanvas->v.pixbuf, 0x00000000);
  } else {
    if (pcanvas->type == CANVAS_PIXCOMM) {
      gtk_pixcomm_clear(pcanvas->v.pixcomm);
    }

    /* Guess */
    width = tileset_full_tile_width(tileset);
    height = tileset_full_tile_height(tileset);
  }

  /* Finally, put a picture of the unit in the tile */
  canvas_put_sprite(pcanvas, 0, 0, sprite, 
      (x2 + x1 - width) / 2, (y1 + y2 - height) / 2, 
      tileset_full_tile_width(tileset) - (x2 + x1 - width) / 2, 
      tileset_full_tile_height(tileset) - (y1 + y2 - height) / 2);
}
コード例 #2
0
ファイル: mapview.c プロジェクト: longturn/freeciv-S2_5
/**************************************************************************
  Draw a full sprite onto the mapview or citydialog canvas.
**************************************************************************/
void canvas_put_sprite_full(struct canvas *pcanvas,
			    int canvas_x, int canvas_y,
			    struct sprite *sprite)
{
  canvas_put_sprite(pcanvas, canvas_x, canvas_y,
		    sprite, 0, 0, sprite->width, sprite->height);
}
コード例 #3
0
ファイル: canvas.c プロジェクト: sylvain121/freeciv-android
/****************************************************************************
  Draw the text onto the canvas in the given color and font.  The canvas
  position does not account for the ascent of the text; this function must
  take care of this manually.  The text will not be NULL but may be empty.
****************************************************************************/
void canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y,
		     enum client_font font, struct color *pcolor,
		     const char *text)
{
  struct sprite *text_holder = sprite_string(text);

  canvas_put_sprite(pcanvas, canvas_x, canvas_y, text_holder, 0, 0, text_holder->width, text_holder->height);
}
コード例 #4
0
ファイル: canvas.c プロジェクト: zielmicha/freeciv-mirror
/****************************************************************************
  Draw a full sprite onto the mapview or citydialog canvas.
****************************************************************************/
void canvas_put_sprite_full(struct canvas *pcanvas,
                            int canvas_x, int canvas_y,
                            struct sprite *sprite)
{
    int width, height;
    get_sprite_dimensions(sprite, &width, &height);
    canvas_put_sprite(pcanvas, canvas_x, canvas_y, sprite,
                      0, 0, width, height);
}
コード例 #5
0
ファイル: mapview.c プロジェクト: valisc/freeciv
/**************************************************************************
  Only used for isometric view.
**************************************************************************/
void pixmap_put_overlay_tile_draw(struct canvas *pcanvas,
				  int canvas_x, int canvas_y,
				  struct sprite *ssprite,
				  bool fog)
{
  cairo_t *cr;
  int sswidth, ssheight;

  if (!ssprite) {
    return;
  }

  get_sprite_dimensions(ssprite, &sswidth, &ssheight);
  canvas_put_sprite(pcanvas, canvas_x, canvas_y,
                    ssprite, 0, 0, sswidth, ssheight);

  if (fog) {
    if (!pcanvas->drawable) {
      cr = cairo_create(pcanvas->surface);
    } else {
      cr = pcanvas->drawable;
    }

    if (pcanvas->drawable) {
      cairo_save(cr);
    }

    cairo_set_operator(cr, CAIRO_OPERATOR_HSL_COLOR);
    cairo_scale(cr, pcanvas->zoom, pcanvas->zoom);
    cairo_set_source_rgb(cr, 0.65, 0.65, 0.65);
    cairo_fill(cr);

    if (!pcanvas->drawable) {
      cairo_destroy(cr);
    } else {
      cairo_restore(cr);
    }
  }
}