Backend

Name

Backend -- 

Synopsis




void        (*HexDrawFuncSDL)               (SDL_Surface *surface,
                                             SDL_Rect *dst_rect,
                                             HexData *data,
                                             SDL_Rect *src_rect);
HexData*    hex_data_new_from_sdl_surface   (SDL_Surface *surface);
HexOverlay* hex_overlay_new_from_sdl_surface
                                            (SDL_Surface *surface,
                                             gint x_offset,
                                             gint y_offset,
                                             guint hex_width);

typedef     HexSDLRegion;
void        hex_sdl_region_free             (HexSDLRegion *region);
HexSDLRegion* hex_get_region_from_width_sdl (guint width);
G_CONST_RETURN HexSDLRegion* hex_get_region_from_width_cached_sdl
                                            (guint width);
gboolean    hex_sdl_region_intersect_rect   (const HexSDLRegion *region,
                                             const SDL_Rect *rect);

void        hex_draw_data_sdl               (SDL_Surface *surface,
                                             HexData *hex,
                                             gint x,
                                             gint y);
void        hex_draw_border_sdl             (SDL_Surface *surface,
                                             Uint32 pixel_value,
                                             guint width,
                                             gint x,
                                             gint y,
                                             HexDirection dir);
void        hex_draw_list_sdl               (SDL_Surface *surface,
                                             HexList *list,
                                             gint x,
                                             gint y);
SDL_Surface* hex_grid_get_sdl_surface       (HexGrid *grid,
                                             SDL_Surface *reference,
                                             gint x,
                                             gint y);

struct      HexEvent;

Description

Details

HexDrawFuncSDL ()

void        (*HexDrawFuncSDL)               (SDL_Surface *surface,
                                             SDL_Rect *dst_rect,
                                             HexData *data,
                                             SDL_Rect *src_rect);

The prototype for the draw function passed to hex_data_new().

surface :

The destination SDL_Surface

dst_rect :

An SDL_Rect indicating the portion of surface to draw to. Only the x and y coordinates of this rect are used.

data :

The source HexData

src_rect :

An SDL_Rect indication the portion of data to draw.


hex_data_new_from_sdl_surface ()

HexData*    hex_data_new_from_sdl_surface   (SDL_Surface *surface);

Creates a new HexData from a SDL_Surface.

surface :

A SDL_Surface containing the data. This must have the aspect ratio given by HEX_HEIGHT().

Returns :

a newly created HexData


hex_overlay_new_from_sdl_surface ()

HexOverlay* hex_overlay_new_from_sdl_surface
                                            (SDL_Surface *surface,
                                             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.

surface :

A SDL_Surface 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 pixbuf

y_offset :

The offset in pixels from the left side of the upper left hex to the left side of the pixbuf

hex_width :

The width of the hexes that will be generated

Returns :

a newly created HexOverlay


HexSDLRegion

A structure representing a region in x-y coordinates, usually a hexagon.


hex_sdl_region_free ()

void        hex_sdl_region_free             (HexSDLRegion *region);

free the region.

region :

A HexSDLRegion.


hex_get_region_from_width_sdl ()

HexSDLRegion* hex_get_region_from_width_sdl (guint width);

get a hexagonal region

width :

The width of the hex. Its height is given by HEX_HEIGHT().

Returns :

a HexSDLRegion describing the area inside the hex


hex_get_region_from_width_cached_sdl ()

G_CONST_RETURN HexSDLRegion* hex_get_region_from_width_cached_sdl
                                            (guint width);

Get a cached hexagonal region. If width is 0, the cache is flushed and NULL is returned.

width :

The width of the hex. Its height is given by HEX_HEIGHT().

Returns :

A HexSDLRegion describing the area inside the hex. This region is cached, and should not be altered by the calling routine. There is no need to destroy this region when you are through using it.


hex_sdl_region_intersect_rect ()

gboolean    hex_sdl_region_intersect_rect   (const HexSDLRegion *region,
                                             const SDL_Rect *rect);

check if a rectangle and a region intersect

region :

A HexSDLRegion.

rect :

An SDL_Rect.

Returns :

TRUE if they intersect


hex_draw_data_sdl ()

void        hex_draw_data_sdl               (SDL_Surface *surface,
                                             HexData *hex,
                                             gint x,
                                             gint y);

Draws the HexData to a GdkDrawable

surface :

the destination SDL_Surface

hex :

the HexData to draw

x :

The x coordinate of the left corner of the HexData

y :

The y coordinate of the top edge of the HexData


hex_draw_border_sdl ()

void        hex_draw_border_sdl             (SDL_Surface *surface,
                                             Uint32 pixel_value,
                                             guint width,
                                             gint x,
                                             gint y,
                                             HexDirection dir);

Draws the border of a hex to a GdkDrawable using the foreground color.

surface :

the destination SDL_Surface

pixel_value :

the pixel value for the color of the border

width :

The width of the hex for which to draw a border. The height of the hex is given by HEX_HEIGHT().

x :

The location of the top of the hex in surface.

y :

The location of the left side of the hex in surface.

dir :

Which sides of the border to draw. To draw all sides, use HEX_DIRECTION_MASK.


hex_draw_list_sdl ()

void        hex_draw_list_sdl               (SDL_Surface *surface,
                                             HexList *list,
                                             gint x,
                                             gint y);

Draws a HexList, with the lowest depth on the bottom and the highest on top (painter's algorithm).

surface :

a SDL_Surface to draw to

list :

a HexList. An empty list can be specified by passing NULL.

x :

the pixel location of the top of the hex

y :

the pixel location of the left corner of the hex


hex_grid_get_sdl_surface ()

SDL_Surface* hex_grid_get_sdl_surface       (HexGrid *grid,
                                             SDL_Surface *reference,
                                             gint x,
                                             gint y);

Gets a surface to which the tiles at location (x, y) are drawn. These surfaces are cached internally.

grid :

a HexGrid

reference :

a reference SDL_Surface used to set color depth, etc.

x :

the x position of a hex

y :

the y position of a hex

Returns :

a SDL_Surface to which the tiles at location (x, y) are drawn


struct HexEvent

struct HexEvent
{
    gint           x, y;  /* Pixel coordinates relative to grid */
    SDL_Event     *event;
    HexDisplaySDL *source;
};

A structure containing an SDL_Event and the coordinates of the hex it happened in.

gint x

The x coordinate of the hex where the event happened.

gint y

The y coordinate of the hex where the event happened.

SDL_Event *event

An SDL_Event

HexDisplaySDL *source

The HexDisplaySDL that received the event.