| 1 | |||
| 2 | # Apple RGB 1998 (illuminant D65, gamma 1.8) | ||
| 3 | |||
| 4 | package Graphics::Toolkit::Color::Space::Instance::AppleRGB; | ||
| 5 | 16 | ▶ | use v5.12; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 16 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 16 | ▶ | use Graphics::Toolkit::Color::Space qw/spow mult_matrix_vector_3/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 16 | my @D65 = (.95047, 1, 1.08883); | |
| 10 | 16 | my $gamma = 1.8; | |
| 11 | |||
| 12 | 4 | ▶ | sub from_rgb { |
|
Subroutine
from_rgb: called CC=2 SCAR=6.9
Pod
undocumented
| |||
| 13 | 4 | my $rgb = shift; | |
| 14 | 4 | $rgb = [map {spow($_, $gamma)} @$rgb]; | |
| 15 | 4 | my @xyz = mult_matrix_vector_3( [[ 0.4497288, 0.3162486, 0.1844926 ], | |
| 16 | [ 0.2446525, 0.6720283, 0.0833192 ], | ||
| 17 | [ 0.0251848, 0.1411824, 0.9224628 ] ], @$rgb); | ||
| 18 | 4 | $xyz[$_] /= $D65[ $_ ] for 0 .. 2; | |
| 19 | 4 | return \@xyz; | |
| 20 | } | ||
| 21 | 4 | ▶ | sub to_rgb { |
|
Subroutine
to_rgb: called CC=2 SCAR=6.9
Pod
undocumented
| |||
| 22 | 4 | my ($xyz) = [ @{$_[0]} ]; | |
| 23 | 4 | $xyz->[$_] *= $D65[ $_ ] for 0 .. 2; | |
| 24 | 4 | my @rgb = mult_matrix_vector_3( [[ 2.9515373, -1.2894116, -0.4738445 ], | |
| 25 | [ -1.0851093, 1.9908566, 0.0372026 ], | ||
| 26 | [ 0.0854934, -0.2694964, 1.0912975 ] ], @$xyz); | ||
| 27 | 4 | return [map {spow($_, 1 / $gamma)} @rgb]; | |
| 28 | } | ||
| 29 | |||
| 30 | 16 | Graphics::Toolkit::Color::Space->new( | |
| 31 | name => 'AppleRGB', | ||
| 32 | family => 'RGB', | ||
| 33 | axis => [qw/red green blue/], | ||
| 34 | precision => 6, | ||
| 35 | convert => {XYZ => [\&from_rgb, \&to_rgb]}, | ||
| 36 | ); | ||