Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions lib/sass/value/color/space/rec2020.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ module Space
class Rec2020
include Space

# A constant used in the rec2020 gamma encoding/decoding functions.
ALPHA = 1.09929682680944

private_constant :ALPHA

# A constant used in the rec2020 gamma encoding/decoding functions.
BETA = 0.018053968510807

private_constant :BETA

def bounded?
true
end
Expand All @@ -27,13 +17,11 @@ def initialize
end

def to_linear(channel)
abs = channel.abs
abs < BETA * 4.5 ? channel / 4.5 : (channel <=> 0) * (((abs + ALPHA - 1) / ALPHA)**(1 / 0.45))
(channel <=> 0) * (channel.abs**2.4)
end

def from_linear(channel)
abs = channel.abs
abs > BETA ? (channel <=> 0) * ((ALPHA * (abs**0.45)) - (ALPHA - 1)) : 4.5 * channel
(channel <=> 0) * (channel.abs**(1 / 2.4))
end

private
Expand Down
6 changes: 3 additions & 3 deletions spec/sass/value/color/interpolation_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,19 @@
{
weight: 0.5
},
[0.5494120530883964, 0.4907232619435038, 0.5681615893671463]
[0.6077246048987993, 0.560474374484174, 0.6287869996304708]
],
[
{
weight: 1
},
[0.8837118321235519, 0.6578067923850563, 0.7273197917658354]
[0.901652581777482, 0.7080066863855734, 0.7679984285088408]
],
[
{
weight: 0
},
[0.21511227405324085, 0.32363973150195124, 0.4090033869684574]
[0.3137966280201166, 0.4129420625827747, 0.48957557075210073]
]
],
xyz: [
Expand Down
4 changes: 2 additions & 2 deletions spec/sass/value/color/spaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ def respond_to_missing?(symbol, _include_all)
name: 'rec2020',
is_legacy: false,
is_polar: false,
pink: [0.883711832123552, 0.6578067923850561, 0.7273197917658352],
blue: [0.21511227405324085, 0.3236397315019512, 0.4090033869684574],
pink: [0.901652581777482, 0.7080066863855734, 0.7679984285088408],
blue: [0.3137966280201166, 0.4129420625827747, 0.48957557075210073],
channels: %w[red green blue],
ranges: [
[0, 1],
Expand Down