02 Apr 2008 22:32:46 UTC
- Distribution: Gtk2-Hexgrid
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (171 / 0 / 1)
- KwaliteeBus factor: 0
- 87.50% Coverage
- License: unknown
- Download (50.23KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- Zach Morgan
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.
Module Install Instructions
To install Gtk2::Hexgrid, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Gtk2::Hexgrid
For more information on module installation, please visit the detailed CPAN module installation guide.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|