| 1 | |||||||||||
| 2 | # Display P3, D65 same transfer function as SRGB | ||||||||||
| 3 | |||||||||||
| 4 | package Graphics::Toolkit::Color::Space::Instance::DisplayP3; | ||||||||||
| 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 | 4 | ▶ | sub from_p3 { | ||||||||
|
Subroutine
from_p3: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 12 | 4 | my ($rgb) = shift; | |||||||||
| 13 | 4 | ▶ | return [ map { (abs($_) > 0.04045) ? spow((($_ + 0.055) / 1.055 ), $gamma) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | : ($_ / 12.92) } @$rgb ]; | ||||||||||
| 15 | } | ||||||||||
| 16 | 4 | ▶ | sub to_p3 { | ||||||||
|
Subroutine
to_p3: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 17 | 4 | my ($lrgb) = shift; | |||||||||
| 18 | 4 | ▶ | return [ map { (abs($_) > 0.0031308) ? ( (spow($_, 1/$gamma) * 1.055) - 0.055) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | : ($_ * 12.92) } @$lrgb ]; | ||||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 16 | Graphics::Toolkit::Color::Space->new( | |||||||||
| 23 | name => 'display-p3', | ||||||||||
| 24 | alias_name => 'P3', | ||||||||||
| 25 | family => 'RGB', | ||||||||||
| 26 | axis => [qw/red green blue/], | ||||||||||
| 27 | precision => 6, | ||||||||||
| 28 | convert => {'Display-P3-Linear' => [\&from_p3, \&to_p3]}, | ||||||||||
| 29 | ); | ||||||||||