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.
See Gtk2::Hexgrid::get_adjacent_tiles
See Gtk2::Hexgrid::get_tile_center
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...
$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.
$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.
$tile->add_sprite($sprite);
Attaches $sprite to $tile.
$tile->remove_sprite($sprite);
Removes $sprite from $tile.
$tile->has_sprite($sprite);
Returns true if $sprite is attached to $tile, else false.
$tile->destroy_background;
Removes background sprites from tile. Actually, it believes that all sprites with a -21.21 priority are background.
$tile->destroy_text;
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.
To install Gtk2::Hexgrid, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gtk2::Hexgrid
CPAN shell
perl -MCPAN -e shell install Gtk2::Hexgrid
For more information on module installation, please visit the detailed CPAN module installation guide.