| 1 | # Perl module for AttributeSet |
| 2 | # Author: Malay < curiouser@ccmb.res.in> |
| 3 | # Copyright Malay |
| 4 | # You may distribute this module under the same terms as perl itself |
| 5 | |
| 6 | # POD documentation - main docs before the code |
| 7 | |
| 8 | =head1 NAME |
| 9 | |
| 10 | AttributeSet - Collection of attributes. |
| 11 | |
| 12 | =head1 SYNOPSIS |
| 13 | |
| 14 | $as = Pastel::AttributeSet->new(); |
| 15 | $fill_color = Pastel::Color->red(); |
| 16 | my $att = Pastel::Attribute->new(-type=>"FILL", -object=>$fill_color); |
| 17 | $as->add_attribute($att); |
| 18 | # Iterate through AttributeSet |
| 19 | while ( $as->has_more() ){ |
| 20 | $attribute = $as->get_attribute(); |
| 21 | print $attribute->to_svg(); |
| 22 | } |
| 23 | |
| 24 | # or get the full thing as SVG |
| 25 | my $svg = $as->to_svg(); |
| 26 | |
| 27 | =head1 DESCRIPTION |
| 28 | |
| 29 | AttributeSet is a collection of Attribute objects. |
| 30 | |
| 31 | =head1 CONTACT |
| 32 | |
| 33 | Malay <curiouser@ccmb.res.in> |
| 34 | |
| 35 | =cut |
| 36 | |
| 37 | # Let the code begin... |
| 38 | |
| 39 | package Pastel::AttributeSet; |
| 40 | @ISA = qw (Pastel::Root); |
| 41 | use Pastel::Root; |
| 42 | use strict; |
| 43 | |
| 44 | =head1 CONSTRUCTOR |
| 45 | |
| 46 | =head2 new() |
| 47 | |
| 48 | Returns an empty AttributeSet object. |
| 49 | |
| 50 | =cut |
| 51 | |
| 52 | # _init is where the heavy stuff will happen when new is called |
| 53 | |
| 54 | sub _init { |
| 55 | my ( $self, @args ) = @_; |
| 56 | $self->{attributes} = []; |
| 57 | return $self; |
| 58 | } |
| 59 | |
| 60 | =head2 add_attribute() |
| 61 | |
| 62 | Usage: |
| 63 | Function: |
| 64 | Example: |
| 65 | Returns: |
| 66 | Arguments |
| 67 | |
| 68 | =cut |
| 69 | |
| 70 | sub add_attribute { |
| 71 | my ( $self, $att ) = @_; |
| 72 | push ( @{ $self->{attributes} }, $att ); |
| 73 | } |
| 74 | |
| 75 | =head1 APPENDIX |
| 76 | |
| 77 | |
| 78 | |
| 79 | =cut |
| 80 | |
| 81 | 1; |