| 1 | |||||||||||
| 2 | # linear standard (S)RGB, RGB with removed gamma | ||||||||||
| 3 | |||||||||||
| 4 | package Graphics::Toolkit::Color::Space::Instance::RGBLinear; | ||||||||||
| 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/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 16 | my $gamma = 2.4; | |||||||||
| 10 | |||||||||||
| 11 | 90 | ▶ | sub from_lrgb { | ||||||||
|
Subroutine
from_lrgb: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 12 | 90 | my ($lrgb) = shift; | |||||||||
| 13 | 90 | ▶ | return [ map { (abs($_) > 0.0031308) ? ((spow($_, 1/$gamma) * 1.055) - 0.055) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | : ($_ * 12.92) } @$lrgb ]; | ||||||||||
| 15 | } | ||||||||||
| 16 | 140 | ▶ | sub to_lrgb { | ||||||||
|
Subroutine
to_lrgb: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 17 | 140 | my ($rgb) = shift; | |||||||||
| 18 | 140 | ▶ | return [ map { (abs($_) > 0.04045) ? spow((($_ + 0.055) / 1.055 ), $gamma) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | : ($_ / 12.92) } @$rgb ]; | ||||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 16 | Graphics::Toolkit::Color::Space->new( | |||||||||
| 23 | name => 'LinearRGB', | ||||||||||
| 24 | alias_name => 'linRGB', | ||||||||||
| 25 | family => 'RGB', | ||||||||||
| 26 | axis => [qw/red green blue/], | ||||||||||
| 27 | precision => 6, | ||||||||||
| 28 | convert => {RGB => [\&from_lrgb, \&to_lrgb]}, | ||||||||||
| 29 | ); | ||||||||||