NAME
HTML::TagCloud::Centred - Biggest tags in the centre
SYNOPSIS
use HTML::TagCloud::Centred;
my $cloud = HTML::TagCloud::Centred->new(
# size_min_pc => 50,
# size_max_pc => 200,
# scale_code => sub { ... },
# html_esc_code => sub { ... },
# clr_max => '#FF0000',
# clr_min => '#550000',
);
$cloud->add( 'FirstWord', 'http://www.google.co.uk' );
foreach my $w (
('Biggest')x7, ('Medium')x5, ('Small')x5, ('Smallest')x10
){
$cloud->add( $w );
}
open my $OUT, '>cloud.html';
# print $OUT $cloud->css;
# print $OUT $cloud->html;
print $OUT $cloud->html_and_css;
close $OUT;
warn 'Tags: ',Dumper $cloud->tags;
exit;
DESCRIPTION
This modules produces a tag cloud with the heaviest words in the centre, and the lightest on the outside, to make it appear a bit like the clouds seen in the sky.
Words are accepted through add in a sorted order - that is, add the heaviest word first, the lightest last. When the html
or css_and_html
methods are called, the words are added to a grid in a simple spiral: this may change to produce a prettier cloud, but it works well enough as it is.
Otherwise, it is API-compatible with HTML::TagCloud, though that module is not required. For further details of this modules methods, please see HTML::TagCloud.
OUTPUT
Output is HTML and/or CSS. The HTML contains a div
of class tagcloud
, that contains one or more div
of class row
. Each row contains a
elements for each linked word. If words were supplied without links, they are contained in span
elements.
Colouring and font-sizing is contained in the a
and span
style
attributes. The base size can of course be set in your CSS, since all sizing is by percentage relevant to the parent container. The CSS supplied is minimal, just to centre the rows.
CONSTRUCTOR (new)
Takes the following optional parameters:
- size_max_pc
-
The maximum font size of the output, as a CSS percentage value. Default is 120.
- size_min_pc
-
The minimum font size of the output, as a CSS percentgage value. Default is half of
size_max_pc
. - scale_code
-
Code reference to calculate the scaling of items in the cloud. Defaults to something reasonable, but could be used to implement logarithmic or exponential scaling. The routine gets called as an instance method. Note that the words added to create the cloud are stored as a list in
words
. - html_esc_code
-
Code referene to escape HTML in the output (text within the cloud and in
a
elementtitle
attributes). Default is to requireCGI::Util
, and callCGI::Util::escape
. The sole argument is the word to escape. - clr_max, clr_min
-
You can supply these as arguments for Color::Spectrum, if you have it installed. See Color::Spectrum. By defaul these values are not set.
SEE ALSO
AUTHOR AND COPYRIGHT
Copyright (C) Lee Goddard, 2010-2011. All Rights Reserved.
This distribution is made available under the same terms as Perl.