Acme-Colour

 view release on metacpan or  search on metacpan

CHANGES  view on Meta::CPAN

    - perltidy
    - add LICENSE, META.yml, examples/acme_colour.pl
    - add perlcritic test

1.03 Fri Sep  8 17:34:37 BST 2006
        - added pod test and pod coverage test
        - perltidy

1.02 Tue Sep 21 14:03:22 BST 2004
        - renamed private methods to start with _
        - documented the default method
        - increased test coverage to 100%

1.01 Fri May 14 16:21:26 BST 2004
	- regenerated with new Module::Build, which means the
	  Makefile.PL now contains Test::Exception

1.00 Sun Sep 28 17:50:26 BST 2003
	- moved to Module::Build
	- throw exceptions using Error when given unknown colours

lib/Acme/Colour.pm  view on Meta::CPAN


    my $self = {};
    bless $self, $class;

    if ( defined $colour ) {
        unless ( exists $r{$colour} ) {
            throw Error::Simple("Colour $colour is unknown");
        }
        $self->{colour} = $colour;
    } else {
        $self->{colour} = $self->default;
    }

    return $self;
}

sub default {
    return "white";
}

sub colour {
    my $self = shift;
    return $self->{colour};
}

sub add {
    my $self   = shift;

lib/Acme/Colour.pm  view on Meta::CPAN


  $c->add("red");

=head2 mix()

The mix() method performs subtractive mixing on the colour. It takes
in the colour to mix in:

  $c->mix("cyan");

=head2 default()

The default() method returns the default colour, white. You may
override this in a subclass.

  $c = Acme::Colour->new(); # white by default

=head1 ALTERNATIVE INTERFACE

There is an alternative interface to this module which overloads
string quoting. This is very cute, but is not recommended in
production code. Strings containing colour names magically get
converted into Acme::Colour objects and additive and subtractive
mixing is performed on these "strings" using "+" and "-":

  use Acme::Colour constants => 1; # note special invocation



( run in 1.076 second using v1.01-cache-2.11-cpan-0a6323c29d9 )