The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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_word( 'FirstWord', 'http://www.google.co.uk' );
        foreach my $w (
                ('Biggest')x7, ('Medium')x5, ('Small')x5, ('Smallest')x10 
        ){
                $cloud->add_word( $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_word 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.

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 element title attributes). Default is to require CGI::Util, and call CGI::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

HTML::TagCloud.

AUTHOR AND COPYRIGHT

Copyright (C) Lee Goddard, 2010-2011. All Rights Reserved.

This distribution is made available under the same terms as Perl.