NAME

Graphics::RGBManipulate - HSV adjustment tool for RGB colours

SYNOPSIS

use Graphics::RGBManipulate;

my ($red, $green, $blue) = Graphics::RGBManipulate::tweak(
	hue => 40,
	red => 255,
	green => 0,
	blue => 0
); # Changes the colour RGB(255, 0, 0) into bright orange

my $hex_string = Graphics::RGBManipulate::tweak(
	hex => $old_hex_string,
	saturation => 0
); # Returns what $old_hex_string would be as greyscale

METHODS

tweak

Adjusts hue, saturation and value for RGB colours. The function accepts the following arguments (passed as a list of pairs (i.e. a hash):

hex

This should be either a three or six character hex string as found in HTML. The preceeding # is optional, and the value you get back will either include or not include it depending on if you included it. If this value is set, you will get back a string rather than an R G B list - it also overrides any red, green, or blue arguments you may pass to &tweak.

red/green/blue

These are values from 0 to 256. They will default to 0. If you invoke &tweak using these values (as opposed to hex) then you'll get a list of the tweaked R G B values back.

hue

If you set this, then the RGB colour will be changed to this hue. If you don't set it, then the hue of the original colour will be preserved. It accepts a degree on the colour wheel - any integer from 0 to 360.

saturation

As with hue, if this is set, the saturation of the colour will be changed. Saturation can be an integer from 0 to 255. Setting it to 0 will render greyscale.

value

As with hue and saturation, if this is set, then the value of the colour will be adjusted. If you've not come across the concept of value before, consider it to be the inverse measure of black paint you would mix with a colour. That is, if the value is 0, then the colour will be black regardless of hue and saturation. If the value is 1, then the colour will be pure... value accepts a percentage in decimal form - that is any number from 0 to 1 (e.g. 0.09).

AUTHOR

Pete Sergeant - pete@clueball.com

COPYRIGHT

Copyright (c) 2002 Peter Sergeant. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.