Acme-Tango

 view release on metacpan or  search on metacpan

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

	$flavour ||= 'orange';

	# Pick the transformation hue
	my $new_hue = $flavours{$flavour};
	croak "Unknown flavour [$flavour]" unless defined $new_hue;

	# Sanity-check the incoming colour
	my $prefix = $hex =~ s/^#// ? '#' : '';
	croak "Please provide a valid hex colour"
		unless $hex =~ m/^([0-9a-f]{3}|[0-9a-f]{6})$/i;
	$hex =~ s/(.)/$1$1/g if length($hex) == 3;

	# Convert to HSV
	my ( $old_hue, $s, $v ) = Convert::Color::RGB8->new( $hex )->as_hsv->hsv;

	# Back to RGB
	my $new_color = Convert::Color::HSV->new( $new_hue, $s, $v )->as_rgb8->hex;

	# Back to the user!
	return uc($prefix . $new_color);
}



( run in 1.463 second using v1.01-cache-2.11-cpan-65fba6d93b7 )