diff --git a/lib/sass/value/color.rb b/lib/sass/value/color.rb index 8eb0662..75f06d0 100644 --- a/lib/sass/value/color.rb +++ b/lib/sass/value/color.rb @@ -569,8 +569,8 @@ def _analogous_channel_missing?(original, output, output_channel_index) return false if original.equal?(output) - output_channel = output.space.channels[output_channel_index] - original_channel = original.space.channels.find do |channel| + output_channel = output._space.channels[output_channel_index] + original_channel = original._space.channels.find do |channel| output_channel.analogous?(channel) end diff --git a/spec/sass/value/color/interpolation_examples.rb b/spec/sass/value/color/interpolation_examples.rb index 68467b1..ff4b507 100644 --- a/spec/sass/value/color/interpolation_examples.rb +++ b/spec/sass/value/color/interpolation_examples.rb @@ -7,7 +7,7 @@ { weight: 0.5 }, - [58.614201646094955, 10.016665992350433, -8.387820174394456] + [58.614201693004674, 10.016667522478151, -8.387819651868517] ], [ { @@ -19,7 +19,7 @@ { weight: 0 }, - [38.95792456574883, -15.169549415088852, -17.792484605053115] + [38.957924659568256, -15.169546354833418, -17.792483560001216] ] ], oklab: [ @@ -27,19 +27,19 @@ { weight: 0.5 }, - [0.6476500020040917, 0.02748550994678843, -0.023408287379941606] + [0.6476500060804854, 0.027485511076670896, -0.023408311310399166] ], [ { weight: 1 }, - [0.8241000000000002, 0.10608808442731632, 0.0015900762693974446] + [0.8241000051752044, 0.10608808769190603, 0.0015900461037656743] ], [ { weight: 0 }, - [0.47120000400818335, -0.05111706453373946, -0.048406651029280656] + [0.47120000698576636, -0.05111706553856424, -0.048406668724564006] ] ], lch: [ @@ -47,7 +47,7 @@ { weight: 0.5 }, - [58.61420164622054, 29.299459370089924, 295.6021177856686] + [58.614201693004674, 29.299457976259603, 295.6021198088788] ], [ { @@ -59,35 +59,35 @@ { weight: 0 }, - [38.957924566, 23.38135449889311, 229.5496923459574] + [38.957924659568256, 23.381351711232465, 229.54969639237788] ], [ { weight: 0.5, method: 'shorter' }, - [58.61420164622054, 29.299459370089924, 295.6021177856686] + [58.614201693004674, 29.299457976259603, 295.6021198088788] ], [ { weight: 0.5, method: 'longer' }, - [58.61420164622054, 29.299459370089924, 115.60211778566858] + [58.614201693004674, 29.299457976259603, 115.6021198088788] ], [ { weight: 0.5, method: 'increasing' }, - [58.61420164622054, 29.299459370089924, 115.60211778566858] + [58.614201693004674, 29.299457976259603, 115.6021198088788] ], [ { weight: 0.5, method: 'decreasing' }, - [58.61420164622054, 29.299459370089924, 295.6021177856686] + [58.614201693004674, 29.299457976259603, 295.6021198088788] ] ], oklch: [ @@ -95,47 +95,47 @@ { weight: 0.5 }, - [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + [0.6476500060804854, 0.0882500012863419, 292.1493473823782] ], [ { weight: 1 }, - [0.8241, 0.1061, 0.8586999999999989] + [0.8241000051752044, 0.1061000028121472, 0.8586836854624949] ], [ { weight: 0 }, - [0.47120000400818335, 0.07039998686375618, 223.4400011847514] + [0.47120000698576636, 0.07039999976053661, 223.44001107929404] ], [ { weight: 0.5, method: 'shorter' }, - [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + [0.6476500060804854, 0.0882500012863419, 292.1493473823782] ], [ { weight: 0.5, method: 'longer' }, - [0.6476500020040917, 0.08824999343187809, 112.1493505923757] + [0.6476500060804854, 0.0882500012863419, 112.14934738237824] ], [ { weight: 0.5, method: 'increasing' }, - [0.6476500020040917, 0.08824999343187809, 112.1493505923757] + [0.6476500060804854, 0.0882500012863419, 112.14934738237824] ], [ { weight: 0.5, method: 'decreasing' }, - [0.6476500020040917, 0.08824999343187809, 292.1493505923757] + [0.6476500060804854, 0.0882500012863419, 292.1493473823782] ] ], srgb: [ @@ -223,7 +223,7 @@ { weight: 0.5 }, - [0.5427623847027483, 0.4757813439417372, 0.5419635636962455] + [0.5427628071521571, 0.4757810859208764, 0.5419635611723659] ], [ { @@ -235,7 +235,7 @@ { weight: 0 }, - [0.2431790331963506, 0.3045087255847488, 0.38356879501347535] + [0.24317987809516806, 0.304508209543027, 0.3835687899657161] ] ], rec2020: [ @@ -283,7 +283,7 @@ { weight: 0.5 }, - [0.3740759617070767, 0.3215358224064546, 0.2908164562135577] + [0.37407596368010154, 0.32153582267804004, 0.29081645447205257] ], [ { @@ -295,7 +295,7 @@ { weight: 0 }, - [0.08408207011375313, 0.10634498228480066, 0.14703708775508573] + [0.08408207405980274, 0.10634498282797152, 0.14703708427207543] ] ], rgb: [ @@ -303,7 +303,7 @@ { weight: 0.5 }, - [146.56944672156501, 134.1448156837381, 157.00580432872178] + [146.49494601036622, 133.9494959758061, 156.77020571682615] ], [ { @@ -315,7 +315,7 @@ { weight: 0 }, - [38.14436413378462, 100.00369046118837, 120.62648929056449] + [37.99536271138702, 99.61305104532435, 120.15529206677323] ] ], hsl: [ diff --git a/spec/sass/value/color/spaces.rb b/spec/sass/value/color/spaces.rb index 6cca474..b18da24 100644 --- a/spec/sass/value/color/spaces.rb +++ b/spec/sass/value/color/spaces.rb @@ -9,8 +9,8 @@ name: 'lab', is_legacy: false, is_polar: false, - pink: [78.27047872644108, 35.20288139978972, 1.0168442562642044], - blue: [38.95792456574883, -15.169549415088856, -17.792484605053115], + pink: [78.27047872644108, 35.20288139978972, 1.0168442562641822], + blue: [38.957924659568256, -15.169546354833418, -17.792483560001216], channels: %w[lightness a b], ranges: [ [0, 100], @@ -30,8 +30,8 @@ name: 'oklab', is_legacy: false, is_polar: false, - pink: [0.8241000000000002, 0.10608808442731632, 0.0015900762693974446], - blue: [0.47120000400818335, -0.05111706453373946, -0.048406651029280656], + pink: [0.8241000051752044, 0.10608808769190603, 0.0015900461037656743], + blue: [0.47120000698576636, -0.05111706553856424, -0.048406668724564006], channels: %w[lightness a b], ranges: [ [0, 1], @@ -51,8 +51,8 @@ name: 'lch', is_legacy: false, is_polar: true, - pink: [78.27047872644108, 35.21756424128674, 1.6545432253797676], - blue: [38.957924566, 23.38135449889311, 229.54969234595737], + pink: [78.27047872644108, 35.21756424128674, 1.6545432253797117], + blue: [38.957924659568256, 23.381351711232465, 229.54969639237788], channels: %w[lightness chroma hue], has_powerless: true, ranges: [ @@ -73,8 +73,8 @@ name: 'oklch', is_legacy: false, is_polar: true, - pink: [0.8241, 0.1061, 0.8587], - blue: [0.47120000400818335, 0.07039998686375618, 223.44000118475142], + pink: [0.8241000051752044, 0.1061000028121472, 0.8586836854624949], + blue: [0.47120000698576636, 0.07039999976053661, 223.44001107929404], channels: %w[lightness chroma hue], has_powerless: true, ranges: [ @@ -95,7 +95,7 @@ name: 'srgb', is_legacy: false, is_polar: false, - pink: [0.9999785463111585, 0.6599448662991679, 0.758373017125016], + pink: [0.9999785463111587, 0.6599448662991679, 0.7583730171250161], blue: [0.14900142239759614, 0.39063941586401707, 0.47119722379126755], channels: %w[red green blue], ranges: [ @@ -113,7 +113,7 @@ name: 'srgb-linear', is_legacy: false, is_polar: false, - pink: [0.999951196094508, 0.3930503811476254, 0.5356603778005655], + pink: [0.9999511960945082, 0.39305038114762536, 0.5356603778005656], blue: [0.019378214827482948, 0.12640222770203852, 0.18834349393523495], channels: %w[red green blue], ranges: [ @@ -149,7 +149,7 @@ name: 'a98-rgb', is_legacy: false, is_polar: false, - pink: [0.9172837001828321, 0.6540226622083835, 0.7491144397116841], + pink: [0.9172837001828322, 0.6540226622083833, 0.749114439711684], blue: [0.2557909283504703, 0.3904466064332277, 0.4651826475952292], channels: %w[red green blue], ranges: [ @@ -167,8 +167,8 @@ name: 'prophoto-rgb', is_legacy: false, is_polar: false, - pink: [0.842345736209146, 0.6470539622987257, 0.7003583323790157], - blue: [0.24317903319635056, 0.3045087255847488, 0.38356879501347535], + pink: [0.842345736209146, 0.6470539622987259, 0.7003583323790157], + blue: [0.24317987809516806, 0.304508209543027, 0.3835687899657161], channels: %w[red green blue], ranges: [ [0, 1], @@ -185,8 +185,8 @@ name: 'rec2020', is_legacy: false, is_polar: false, - pink: [0.8837118321235519, 0.6578067923850563, 0.7273197917658354], - blue: [0.2151122740532409, 0.32363973150195124, 0.4090033869684574], + pink: [0.883711832123552, 0.6578067923850561, 0.7273197917658352], + blue: [0.21511227405324085, 0.3236397315019512, 0.4090033869684574], channels: %w[red green blue], ranges: [ [0, 1], @@ -224,8 +224,8 @@ name: 'xyz-d50', is_legacy: false, is_polar: false, - pink: [0.6640698533004002, 0.5367266625281085, 0.4345958246720296], - blue: [0.08408207011375313, 0.10634498228480066, 0.1470370877550857], + pink: [0.6640698533004004, 0.5367266625281086, 0.43459582467202973], + blue: [0.08408207405980274, 0.10634498282797152, 0.14703708427207543], channels: %w[x y z], ranges: [ [0, 1], @@ -266,8 +266,8 @@ name: 'rgb', is_legacy: true, is_polar: false, - pink: [254.9945293093454, 168.28594090628783, 193.38511936687908], - blue: [38.144364133784602, 100.003690461188378, 120.626489290564506], + pink: [254.99452930934547, 168.28594090628783, 193.3851193668791], + blue: [37.99536271138702, 99.61305104532435, 120.15529206677323], channels: %w[red green blue], ranges: [ [0, 255], @@ -287,7 +287,7 @@ name: 'hsl', is_legacy: true, is_polar: true, - pink: [342.63204677447646, 99.98738302509669, 82.99617063051632], + pink: [342.63204677447646, 99.98738302509679, 82.99617063051633], blue: [195.0016494775154, 51.95041997811069, 31.009932309443183], channels: %w[hue saturation lightness], has_powerless: true, @@ -302,7 +302,7 @@ [0.5, 110, 50], { clip: [0.5, 100, 50], - 'local-minde': [2.9140262667138472, 100, 52.05146874647547] + 'local-minde': [2.9140266584158057, 100, 52.05146824961835] } ] ] @@ -312,7 +312,7 @@ name: 'hwb', is_legacy: true, is_polar: true, - pink: [342.63204677447646, 65.99448662991679, 0.002145368884157506], + pink: [342.63204677447646, 65.9944866299168, 0.002145368884129084], blue: [195.0016494775154, 14.900142239759612, 52.880277620873244], channels: %w[hue whiteness blackness], has_powerless: true, @@ -327,7 +327,7 @@ [0.5, -3, -7], { clip: [0.5, 0, 0], - 'local-minde': [3.492121744609392, 11.26651892207301, 0] + 'local-minde': [3.492122559065345, 11.266517197307957, 0] } ] ] diff --git a/spec/sass/value/color_4_conversions_spec.rb b/spec/sass/value/color_4_conversions_spec.rb index 6bb03fa..a341a64 100644 --- a/spec/sass/value/color_4_conversions_spec.rb +++ b/spec/sass/value/color_4_conversions_spec.rb @@ -155,5 +155,21 @@ end end end + + describe 'interpolate()' do + it 'interpolates a rectangular space without options' do + expect( + described_class.new(red: 100, green: 200, blue: 50) + .interpolate(described_class.new(red: 255, green: 255, blue: 255)) + ).to eq(described_class.new(red: 177.5, green: 227.5, blue: 152.5)) + end + + it 'interpolates a polar space without options' do + expect( + described_class.new(hue: 180, saturation: 100, lightness: 50) + .interpolate(described_class.new(red: 100, green: 200, blue: 50)) + ).to eq(described_class.new(hue: 140, saturation: 80, lightness: 49.509803921568626)) + end + end end end diff --git a/spec/sass/value/color_4_nonparametizable_spec.rb b/spec/sass/value/color_4_nonparametizable_spec.rb index 1cdf286..ffd0233 100644 --- a/spec/sass/value/color_4_nonparametizable_spec.rb +++ b/spec/sass/value/color_4_nonparametizable_spec.rb @@ -14,14 +14,14 @@ 'display-p3', { 'local-minde': ColorConstructors.oklch( - 0.8077756841698541, - 0.3262439045095262, - 148.12027402754507 + 0.8077756760084225, + 0.32624391948277537, + 148.1202761637585 ), clip: ColorConstructors.oklch( - 0.848829286984103, - 0.3685278106366152, - 145.64495037017775 + 0.8488292928532466, + 0.3685277976813825, + 145.64495558662838 ) } ], @@ -30,14 +30,14 @@ 'srgb', { 'local-minde': ColorConstructors.oklch( - 0.809152570178515, - 0.23790275760347995, - 147.40214776873552 + 0.809152561530627, + 0.23790276994468387, + 147.40215048389234 ), clip: ColorConstructors.oklch( - 0.8664396115356694, - 0.2948272403370167, - 142.49533888780996 + 0.8664396175234368, + 0.2948272245426958, + 142.4953450414439 ) } ] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b281b28..c056fe7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,8 +44,7 @@ supports_block_expectations end -# TODO: test with higher precision -precision = Sass::Value.const_get(:FuzzyMath)::PRECISION - 6 +precision = Sass::Value.const_get(:FuzzyMath)::PRECISION + 1 RSpec::Matchers.matcher :fuzzy_eq do |expected| match do |actual| @@ -56,7 +55,7 @@ expect(actual.channels_or_nil).to fuzzy_match_array(expected.channels_or_nil) expect(actual.channel_missing?('alpha')).to eq(expected.channel_missing?('alpha')) expect(actual.alpha).to fuzzy_eq(expected.alpha) - # expect(actual).to eq(expected) + expect(actual).to eq(expected) when Numeric expect(actual).to be_within(10**-precision).of(expected) else