NAME

Math::Color - Perl class to represent colors

TREE

-+- Math::Vector -+- Math::Vec3 -+- Math::Color

SEE ALSO

PDL for scientific and bulk numeric data processing and display

Math

Math::Vectors

Math::Color, Math::ColorRGBA, Math::Image, Math::Vec2, Math::Vec3, Math::Rotation

SYNOPSIS

use Math::Vectors;
my $c = new Math::Color;  # Make a new Color

my $c1 = new Math::Color(0,1,0);

DESCRIPTION

DefaultValue

0 0 0

METHODS

new(r,g,b)

r, g, b are given on [0, 1].

my $c = new Math::Color; 					  
my $c2 = new Math::Color(0, 0.5, 1);   
my $c3 = new Math::Color([0, 0.5, 1]); 

copy

Makes a copy

$c2 = $c1->copy;

setValue(r,g,b)

Sets the value of the color. r, g, b are given on [0, 1].

$c1->setValue(0, 0.2, 1);

setRed(r)

Sets the first value of the color r is given on [0, 1].

$c1->setRed(1);

setGreen(g)

Sets the second value of the color. g is given on [0, 1].

$c1->setGreen(0.2);

setBlue(b)

Sets the third value of the color. b is given on [0, 1].

$c1->setBlue(0.3);

getValue

Returns the value of the color (r, g, b) as a 3 components array.

@v = $c1->getValue;

getRed

Returns the first value of the color.

$r = $c1->getRed;

getGreen

Returns the second value of the color.

$g = $c1->getGreen;

getBlue

Returns the third value of the color.

$b = $c1->getBlue;

setHSV(h,s,v)

h is given on [0, 2 PI]. s, v are given on [0, 1]. RGB are each returned on [0, 1].

$c->setHSV(1/12,1,1);  # 1 0.5 0

getHSV

h is in [0, 2 PI]. s, v are each returned on [0, 1].

@hsv = $c->getHSV;

inverse

Returns the inverse of the color. This is used to overload the '~' operator.

$v = new Math::Color(0, 0.1, 1);
$v = $v1->inverse;  # 1 0.9 0
$v = -$v1;         # 1 0.9 0

toString

Returns a string representation of the color. This is used to overload the '""' operator, so that color may be freely interpolated in strings.

my $c = new Math::Color(0.1, 0.2, 0.3);
print $c->toString; # "0.1, 0.2, 0.3"
print "$c";         # "0.1, 0.2, 0.3"

SEE ALSO

PDL for scientific and bulk numeric data processing and display

Math

Math::Vectors

Math::Color, Math::ColorRGBA, Math::Image, Math::Vec2, Math::Vec3, Math::Rotation

BUGS & SUGGESTIONS

If you run into a miscalculation or need some sort of feature please drop the author a note.

ARRANGED BY

Holger Seelig holger.seelig@yahoo.de

COPYRIGHT

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.