The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Gtk2::Hexgrid::Tile - a hexagonal tile from a Hexgrid

SYNOPSIS

 my @tiles = $hexgrid->get_all_tiles;
 my $tile = $hexgrid->get_tile(3,5);
 my $column = $tile->col;
 my ($col, $row) = $tile->colrow;
 my ($r, $g, $b) = $tile->rgb;
 $tile->set_color(.1, .65, .35);
 $tile->set_text('Clowndog', 13);
 $tile->destroy_text;
 $tile2 = $tile->southwest;

DESCRIPTION

CONSTRUCTOR

new

 my $tile = new Gtk2::Hexgrid::Tile ($hexgrid, $col, $row, $r, $g, $b)

There's probably no reason to learn the constructor: Tiles are automatically generated with your hexgrid. $hexgrid, $col, $row are there so it knows. $r, $g, $b are it's default color, and it may be changed later.

METHODS

accessors

rgb
col
row
colrow
hexgrid
background
sprites

get_adjacent

See Gtk2::Hexgrid::get_adjacent_tiles

get_center

See Gtk2::Hexgrid::get_tile_center

relative locating

Methods are provided to find whatever tile is adjacent in a specific direction. These return the adjacent tile if it exists, else undef.

 $tile->north
 $tile->n
 $tile->northeast
 $tile->ne
 etc...
north
n
northeast
ne
southeast
se
south
s
southwest
sw
northwest
nw
next_by_direction

set_background

 $tile->set_background("data/onion.png");

Loads a png file, scales it to tile size, and has $tile draw it first whenever it needs drawn.

Backgrounds are cached, so dont worry about loading the same file more than once Backgrounds are given a low (-21.21) priority so that they are drawn first.

Not redrawn automatically.

set_color

 $tile->set_color($r, $g, $b);

Cairo colors (range is 0 to 1). Not redrawn automatically

set_text

 my $size = 14
 $tile->set_text('uoewriu', $size) = @_;

Text is given a priority of 21.21. If you want to paint over it, give something a higher prioriry. Not redrawn automatically.

add_sprite

 $tile->add_sprite($sprite);

Attaches $sprite to $tile.

remove_sprite

 $tile->remove_sprite($sprite);

Removes $sprite from $tile.

has_sprite

 $tile->has_sprite($sprite);

Returns true if $sprite is attached to $tile, else false.

destroy_background

 $tile->destroy_background;

Removes background sprites from tile. Actually, it believes that all sprites with a -21.21 priority are background.

destroy_text

 $tile->destroy_text;

Removes all text sprites from tile. Actually, it believes that all sprites with a 21.21 priority are text sprites.

draw

 $tile->draw();
 $tile->draw($r, $g, $b);

Draws tile using tile's color unless another color is given. Associated with $hexgrid->draw_tile and $hexgrid->draw_tile_ref.