Overlays

Name

Overlays -- Multi-Hex Images

Synopsis


#include <hexmap.h>



struct      HexOverlay;

HexData*    (*HexOverlayFunc)               (gint x_offset,
                                             gint y_offset,
                                             guint hex_width,
                                             gpointer data);
HexOverlay* hex_overlay_new                 (gint x_offset,
                                             gint y_offset,
                                             guint width,
                                             guint height,
                                             guint hex_width,
                                             HexOverlayFunc func,
                                             gpointer data);

HexOverlay* hex_overlay_new_from_xpm_d      (const gchar **xpm_d,
                                             gint x_offset,
                                             gint y_offset,
                                             guint hex_width);
HexOverlay* hex_overlay_new_from_file       (const gchar *filename,
                                             gint x_offset,
                                             gint y_offset,
                                             guint hex_width,
                                             GError **err);
void        hex_overlay_ref                 (HexOverlay *overlay);
void        hex_overlay_unref               (HexOverlay *overlay);
HexData*    hex_overlay_get_hex             (HexOverlay *overlay,
                                             gint x,
                                             gint y);

Description

Details

struct HexOverlay

struct HexOverlay {
  guint ref_count;
  gint x_offset;
  gint y_offset;
  guint width;
  guint height;
  guint hex_width;
  HexData ***data;
};

A structure used for overlaying an image across many hexes


HexOverlayFunc ()

HexData*    (*HexOverlayFunc)               (gint x_offset,
                                             gint y_offset,
                                             guint hex_width,
                                             gpointer data);

A function passed to hex_overlay_new() to create the individual hexes from the bulk image data.

x_offset :

The x offset of the hex within the image.

y_offset :

The y offset of the hex within the image.

hex_width :

The width of the hex.

data :

The bulk image data.

Returns :

A newly created HexData, or NULL if the image is completely transparent in this hex.


hex_overlay_new ()

HexOverlay* hex_overlay_new                 (gint x_offset,
                                             gint y_offset,
                                             guint width,
                                             guint height,
                                             guint hex_width,
                                             HexOverlayFunc func,
                                             gpointer data);

Creates a new HexOverlay

x_offset :

The offset from the upper left corner of the first hex to the left side of the image.

y_offset :

The offset from the upper left corner of the first hex to the top of the image.

width :

The width of the image.

height :

The height of the image.

hex_width :

The width of the HexData to be contained in the HexOverlay

func :

A function which creates a HexData at a given position from the image data. This function may return NULL if the image is completely transparent at this hex.

data :

The image data.

Returns :

a newly created HexOverlay object


hex_overlay_new_from_xpm_d ()

HexOverlay* hex_overlay_new_from_xpm_d      (const gchar **xpm_d,
                                             gint x_offset,
                                             gint y_offset,
                                             guint hex_width);

A HexOverlay is a means of placing an image on a HexGrid by breaking it into several HexData objects.

xpm_d :

Some xpm data which will span one or more hexes.

x_offset :

The offset in pixels from the top of the upper left hex to the top of the xpm data.

y_offset :

The offset in pixels from the left side of the upper left hex to the left side of the xpm data.

hex_width :

The width of the hexes that will be generated.

Returns :

a newly created HexOverlay


hex_overlay_new_from_file ()

HexOverlay* hex_overlay_new_from_file       (const gchar *filename,
                                             gint x_offset,
                                             gint y_offset,
                                             guint hex_width,
                                             GError **err);

A HexOverlay is a means of placing an image on a HexGrid by breaking it into several HexData objects.

filename :

A file containing an image which will span one or more hexes.

x_offset :

The offset in pixels from the top of the upper left hex to the top of the xpm data.

y_offset :

The offset in pixels from the left side of the upper left hex to the left side of the xpm data.

hex_width :

The width of the hexes that will be generated.

err :

A location to return errors generated while loading the file.

Returns :

a newly created HexOverlay


hex_overlay_ref ()

void        hex_overlay_ref                 (HexOverlay *overlay);

Increments the reference count on a HexOverlay.

overlay :

A HexOverlay


hex_overlay_unref ()

void        hex_overlay_unref               (HexOverlay *overlay);

Decrements the reference count on a HexOverlay, and frees it if the count falls to zero.

overlay :

A HexOverlay


hex_overlay_get_hex ()

HexData*    hex_overlay_get_hex             (HexOverlay *overlay,
                                             gint x,
                                             gint y);

get a particular HexData from a HexOverlay

overlay :

A HexOverlay

x :

the x coordinate of the hex

y :

the y coordinate of the hex

Returns :

The HexData at the coordinate (x, y) in the HexOverlay. If no such HexData exists, returns NULL.