Gtk2::Hexgrid::Tile - a hexagonal tile from a Hexgrid
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;
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 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...
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.
$tile->set_color($r, $g, $b);
Cairo colors (range is 0 to 1). Not redrawn automatically
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.
Attaches $sprite to $tile.
Removes $sprite from $tile.
Returns true if $sprite is attached to $tile, else false.
Removes background sprites from tile. Actually, it believes that all sprites with a -21.21 priority are background.
Removes all text sprites from tile. Actually, it believes that all sprites with a 21.21 priority are text sprites.
$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.