git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
perl: minor rewording of a few descriptions
[sheet.git]
/
Shiar_Sheet
/
Colour.pm
diff --git
a/Shiar_Sheet/Colour.pm
b/Shiar_Sheet/Colour.pm
index cedfdfb9e31aa722ff8027657fba1b97c455fb26..cf22f3eac9726d4a6c86f10e66de932e0347f85a 100644
(file)
--- a/
Shiar_Sheet/Colour.pm
+++ b/
Shiar_Sheet/Colour.pm
@@
-4,7
+4,7
@@
use strict;
use warnings;
use List::Util qw( min max );
use warnings;
use List::Util qw( min max );
-our $VERSION = '1.0
2
';
+our $VERSION = '1.0
4
';
# ITU-R recommendation 601 luma co-efficients
our $kr = .299;
# ITU-R recommendation 601 luma co-efficients
our $kr = .299;
@@
-42,9
+42,18
@@
sub luminance {
}
sub hue {
}
sub hue {
+ # colour shift (red = 0 .. 1)
my ($r, $g, $b) = @{ $_[0] };
my $hue = atan2 sqrt(3) * ($g - $b), $r*2 - $g - $b;
my ($r, $g, $b) = @{ $_[0] };
my $hue = atan2 sqrt(3) * ($g - $b), $r*2 - $g - $b;
- return ($hue + $PI) / $PI / 2; # 0 .. 1
+ $hue /= $PI * 2; # -.5 .. .5
+ $hue++ if $hue < 0; # fp $hue %= 1
+ return $hue;
+}
+
+sub hsv {
+ my ($rgb) = @_;
+ my $v = max(@{$rgb});
+ return $rgb->hue, abs(min(@{$rgb}) - $v), $v;
}
sub rgb24 {
}
sub rgb24 {