sass-embedded 1.107.0-aarch64-mswin64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +48 -0
  4. data/exe/sass +13 -0
  5. data/lib/sass/calculation_value/calculation_operation.rb +49 -0
  6. data/lib/sass/calculation_value.rb +22 -0
  7. data/lib/sass/canonicalize_context.rb +25 -0
  8. data/lib/sass/cli.rb +12 -0
  9. data/lib/sass/compile_result.rb +24 -0
  10. data/lib/sass/compiler/channel.rb +70 -0
  11. data/lib/sass/compiler/connection.rb +109 -0
  12. data/lib/sass/compiler/dispatcher.rb +142 -0
  13. data/lib/sass/compiler/session/function_registry.rb +88 -0
  14. data/lib/sass/compiler/session/importer_registry.rb +190 -0
  15. data/lib/sass/compiler/session/logger_registry.rb +99 -0
  16. data/lib/sass/compiler/session/path.rb +23 -0
  17. data/lib/sass/compiler/session/protofier.rb +384 -0
  18. data/lib/sass/compiler/session/stack_trace.rb +46 -0
  19. data/lib/sass/compiler/session.rb +242 -0
  20. data/lib/sass/compiler/varint.rb +39 -0
  21. data/lib/sass/compiler.rb +214 -0
  22. data/lib/sass/dart-sass/sass.bat +7 -0
  23. data/lib/sass/dart-sass/src/LICENSE +1659 -0
  24. data/lib/sass/dart-sass/src/dart.exe +0 -0
  25. data/lib/sass/dart-sass/src/sass.snapshot +0 -0
  26. data/lib/sass/elf.rb +386 -0
  27. data/lib/sass/embedded/version.rb +7 -0
  28. data/lib/sass/embedded.rb +67 -0
  29. data/lib/sass/embedded_protocol.rb +10 -0
  30. data/lib/sass/embedded_sass_pb.rb +62 -0
  31. data/lib/sass/exception.rb +73 -0
  32. data/lib/sass/fork_tracker.rb +56 -0
  33. data/lib/sass/gem_package_importer.rb +28 -0
  34. data/lib/sass/logger/silent.rb +28 -0
  35. data/lib/sass/logger/source_location.rb +22 -0
  36. data/lib/sass/logger/source_span.rb +28 -0
  37. data/lib/sass/node_package_importer.rb +17 -0
  38. data/lib/sass/serializer.rb +30 -0
  39. data/lib/sass/uri.rb +56 -0
  40. data/lib/sass/value/argument_list.rb +29 -0
  41. data/lib/sass/value/boolean.rb +59 -0
  42. data/lib/sass/value/calculation.rb +90 -0
  43. data/lib/sass/value/color/channel.rb +79 -0
  44. data/lib/sass/value/color/conversions.rb +473 -0
  45. data/lib/sass/value/color/gamut_map_method/clip.rb +45 -0
  46. data/lib/sass/value/color/gamut_map_method/local_minde.rb +94 -0
  47. data/lib/sass/value/color/gamut_map_method.rb +45 -0
  48. data/lib/sass/value/color/interpolation_method.rb +51 -0
  49. data/lib/sass/value/color/space/a98_rgb.rb +57 -0
  50. data/lib/sass/value/color/space/display_p3.rb +72 -0
  51. data/lib/sass/value/color/space/display_p3_linear.rb +72 -0
  52. data/lib/sass/value/color/space/hsl.rb +65 -0
  53. data/lib/sass/value/color/space/hwb.rb +94 -0
  54. data/lib/sass/value/color/space/lab.rb +85 -0
  55. data/lib/sass/value/color/space/lch.rb +53 -0
  56. data/lib/sass/value/color/space/lms.rb +146 -0
  57. data/lib/sass/value/color/space/oklab.rb +71 -0
  58. data/lib/sass/value/color/space/oklch.rb +54 -0
  59. data/lib/sass/value/color/space/prophoto_rgb.rb +59 -0
  60. data/lib/sass/value/color/space/rec2020.rb +57 -0
  61. data/lib/sass/value/color/space/rgb.rb +52 -0
  62. data/lib/sass/value/color/space/srgb.rb +145 -0
  63. data/lib/sass/value/color/space/srgb_linear.rb +72 -0
  64. data/lib/sass/value/color/space/utils.rb +89 -0
  65. data/lib/sass/value/color/space/xyz_d50.rb +113 -0
  66. data/lib/sass/value/color/space/xyz_d65.rb +57 -0
  67. data/lib/sass/value/color/space.rb +218 -0
  68. data/lib/sass/value/color.rb +631 -0
  69. data/lib/sass/value/function.rb +66 -0
  70. data/lib/sass/value/fuzzy_math.rb +84 -0
  71. data/lib/sass/value/list.rb +89 -0
  72. data/lib/sass/value/map.rb +77 -0
  73. data/lib/sass/value/mixin.rb +47 -0
  74. data/lib/sass/value/module.rb +47 -0
  75. data/lib/sass/value/null.rb +58 -0
  76. data/lib/sass/value/number/unit.rb +187 -0
  77. data/lib/sass/value/number.rb +364 -0
  78. data/lib/sass/value/string.rb +78 -0
  79. data/lib/sass/value.rb +174 -0
  80. data/lib/sass-embedded.rb +4 -0
  81. metadata +140 -0
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/interpolation_method.dart
7
+ class InterpolationMethod
8
+ # @return [Space]
9
+ attr_reader :space
10
+
11
+ # @return [Symbol, nil]
12
+ attr_reader :hue
13
+
14
+ # @param space [Space]
15
+ # @param hue [Symbol]
16
+ def initialize(space, hue = nil)
17
+ @space = space
18
+ @hue = if space.polar?
19
+ hue.nil? ? :shorter : hue
20
+ end
21
+
22
+ return unless !space.polar? && !hue.nil?
23
+
24
+ raise Sass::ScriptError,
25
+ "Hue interpolation method may not be set for rectangular color space #{space.name}."
26
+ end
27
+ end
28
+
29
+ private_constant :InterpolationMethod
30
+
31
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/interpolation_method.dart
32
+ module HueInterpolationMethod
33
+ class << self
34
+ # @param name [::String]
35
+ # @param argument_name [::String]
36
+ # @return [Symbol]
37
+ def from_name(name, argument_name = nil)
38
+ case name
39
+ when 'decreasing', 'increasing', 'longer', 'shorter'
40
+ name.to_sym
41
+ else
42
+ raise Sass::ScriptError.new("Unknown hue interpolation method \"#{name}\".", argument_name)
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ private_constant :HueInterpolationMethod
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ module Space
7
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/a98_rgb.dart
8
+ class A98Rgb
9
+ include Space
10
+
11
+ def bounded?
12
+ true
13
+ end
14
+
15
+ def initialize
16
+ super('a98-rgb', Utils::RGB_CHANNELS)
17
+ end
18
+
19
+ def to_linear(channel)
20
+ (channel <=> 0) * (channel.abs**(563 / 256.0))
21
+ end
22
+
23
+ def from_linear(channel)
24
+ (channel <=> 0) * (channel.abs**(256 / 563.0))
25
+ end
26
+
27
+ private
28
+
29
+ def transformation_matrix(dest)
30
+ case dest
31
+ when DISPLAY_P3, DISPLAY_P3_LINEAR
32
+ Conversions::LINEAR_A98_RGB_TO_LINEAR_DISPLAY_P3
33
+ when LMS
34
+ Conversions::LINEAR_A98_RGB_TO_LMS
35
+ when PROPHOTO_RGB
36
+ Conversions::LINEAR_A98_RGB_TO_LINEAR_PROPHOTO_RGB
37
+ when REC2020
38
+ Conversions::LINEAR_A98_RGB_TO_LINEAR_REC2020
39
+ when RGB, SRGB, SRGB_LINEAR
40
+ Conversions::LINEAR_A98_RGB_TO_LINEAR_SRGB
41
+ when XYZ_D50
42
+ Conversions::LINEAR_A98_RGB_TO_XYZ_D50
43
+ when XYZ_D65
44
+ Conversions::LINEAR_A98_RGB_TO_XYZ_D65
45
+ else
46
+ super
47
+ end
48
+ end
49
+ end
50
+
51
+ private_constant :A98Rgb
52
+
53
+ A98_RGB = A98Rgb.new
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ module Space
7
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/display_p3.dart
8
+ class DisplayP3
9
+ include Space
10
+
11
+ def bounded?
12
+ true
13
+ end
14
+
15
+ def initialize
16
+ super('display-p3', Utils::RGB_CHANNELS)
17
+ end
18
+
19
+ def convert(dest, red, green, blue, alpha)
20
+ if dest == DISPLAY_P3_LINEAR
21
+ Color.send(
22
+ :for_space_internal,
23
+ dest,
24
+ red.nil? ? nil : to_linear(red),
25
+ green.nil? ? nil : to_linear(green),
26
+ blue.nil? ? nil : to_linear(blue),
27
+ alpha
28
+ )
29
+ else
30
+ convert_linear(dest, red, green, blue, alpha)
31
+ end
32
+ end
33
+
34
+ def to_linear(channel)
35
+ Utils.srgb_and_display_p3_to_linear(channel)
36
+ end
37
+
38
+ def from_linear(channel)
39
+ Utils.srgb_and_display_p3_from_linear(channel)
40
+ end
41
+
42
+ private
43
+
44
+ def transformation_matrix(dest)
45
+ case dest
46
+ when A98_RGB
47
+ Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_A98_RGB
48
+ when LMS
49
+ Conversions::LINEAR_DISPLAY_P3_TO_LMS
50
+ when PROPHOTO_RGB
51
+ Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_PROPHOTO_RGB
52
+ when REC2020
53
+ Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_REC2020
54
+ when RGB, SRGB, SRGB_LINEAR
55
+ Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_SRGB
56
+ when XYZ_D50
57
+ Conversions::LINEAR_DISPLAY_P3_TO_XYZ_D50
58
+ when XYZ_D65
59
+ Conversions::LINEAR_DISPLAY_P3_TO_XYZ_D65
60
+ else
61
+ super
62
+ end
63
+ end
64
+ end
65
+
66
+ private_constant :DisplayP3
67
+
68
+ DISPLAY_P3 = DisplayP3.new
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ module Space
7
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/display_p3_linear.dart
8
+ class DisplayP3Linear
9
+ include Space
10
+
11
+ def bounded?
12
+ true
13
+ end
14
+
15
+ def initialize
16
+ super('display-p3-linear', Utils::RGB_CHANNELS)
17
+ end
18
+
19
+ def convert(dest, red, green, blue, alpha)
20
+ if dest == DISPLAY_P3
21
+ Color.send(
22
+ :for_space_internal,
23
+ dest,
24
+ red.nil? ? nil : Utils.srgb_and_display_p3_from_linear(red),
25
+ green.nil? ? nil : Utils.srgb_and_display_p3_from_linear(green),
26
+ blue.nil? ? nil : Utils.srgb_and_display_p3_from_linear(blue),
27
+ alpha
28
+ )
29
+ else
30
+ super
31
+ end
32
+ end
33
+
34
+ def to_linear(channel)
35
+ channel
36
+ end
37
+
38
+ def from_linear(channel)
39
+ channel
40
+ end
41
+
42
+ private
43
+
44
+ def transformation_matrix(dest)
45
+ case dest
46
+ when A98_RGB
47
+ Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_A98_RGB
48
+ when LMS
49
+ Conversions::LINEAR_DISPLAY_P3_TO_LMS
50
+ when PROPHOTO_RGB
51
+ Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_PROPHOTO_RGB
52
+ when REC2020
53
+ Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_REC2020
54
+ when RGB, SRGB, SRGB_LINEAR
55
+ Conversions::LINEAR_DISPLAY_P3_TO_LINEAR_SRGB
56
+ when XYZ_D50
57
+ Conversions::LINEAR_DISPLAY_P3_TO_XYZ_D50
58
+ when XYZ_D65
59
+ Conversions::LINEAR_DISPLAY_P3_TO_XYZ_D65
60
+ else
61
+ super
62
+ end
63
+ end
64
+ end
65
+
66
+ private_constant :DisplayP3Linear
67
+
68
+ DISPLAY_P3_LINEAR = DisplayP3Linear.new
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ module Space
7
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/hsl.dart
8
+ class Hsl
9
+ include Space
10
+
11
+ def bounded?
12
+ true
13
+ end
14
+
15
+ def legacy?
16
+ true
17
+ end
18
+
19
+ def polar?
20
+ true
21
+ end
22
+
23
+ def initialize
24
+ super('hsl', [
25
+ Utils::HUE_CHANNEL,
26
+ LinearChannel.new('saturation', 0, 100, requires_percent: true, lower_clamped: true).freeze,
27
+ LinearChannel.new('lightness', 0, 100, requires_percent: true).freeze
28
+ ].freeze)
29
+ end
30
+
31
+ def convert(dest, hue, saturation, lightness, alpha)
32
+ missing_lightness = lightness.nil?
33
+ missing_chroma = saturation.nil?
34
+ missing_hue = hue.nil?
35
+
36
+ hue = ((hue.nil? ? 0 : hue) % 360) / 30.0
37
+ saturation = (saturation.nil? ? 0 : saturation) / 100.0
38
+ lightness = (lightness.nil? ? 0 : lightness) / 100.0
39
+
40
+ a = saturation * [lightness, 1 - lightness].min
41
+ f = lambda do |n|
42
+ k = (n + hue) % 12
43
+ lightness - (a * [-1, [k - 3, 9 - k, 1].min].max)
44
+ end
45
+
46
+ SRGB.convert(
47
+ dest,
48
+ f.call(0),
49
+ f.call(8),
50
+ f.call(4),
51
+ alpha,
52
+ missing_lightness:,
53
+ missing_chroma:,
54
+ missing_hue:
55
+ )
56
+ end
57
+ end
58
+
59
+ private_constant :Hsl
60
+
61
+ HSL = Hsl.new
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ module Space
7
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/hwb.dart
8
+ class Hwb
9
+ include Space
10
+
11
+ def bounded?
12
+ true
13
+ end
14
+
15
+ def legacy?
16
+ true
17
+ end
18
+
19
+ def polar?
20
+ true
21
+ end
22
+
23
+ def initialize
24
+ super('hwb', [
25
+ Utils::HUE_CHANNEL,
26
+ LinearChannel.new('whiteness', 0, 100, requires_percent: true).freeze,
27
+ LinearChannel.new('blackness', 0, 100, requires_percent: true).freeze
28
+ ].freeze)
29
+ end
30
+
31
+ def convert(dest, hue, whiteness, blackness, alpha)
32
+ if whiteness.nil? && blackness.nil?
33
+ return Color.send(:_for_space, dest, nil, nil, nil, alpha) if hue.nil?
34
+
35
+ converted = convert(dest, hue, 0, 0, alpha)
36
+ return case dest
37
+ when HSL
38
+ Color.send(:_for_space,
39
+ dest,
40
+ converted.channel0,
41
+ nil,
42
+ nil,
43
+ converted.alpha)
44
+ when LCH, OKLCH
45
+ Color.send(:_for_space,
46
+ dest,
47
+ nil,
48
+ nil,
49
+ converted.channel2,
50
+ converted.alpha)
51
+ else
52
+ converted
53
+ end
54
+ end
55
+
56
+ missing_hue = hue.nil?
57
+
58
+ hue = ((hue.nil? ? 0 : hue) % 360) / 30.0
59
+ whiteness = (whiteness.nil? ? 0 : whiteness) / 100.0
60
+ blackness = (blackness.nil? ? 0 : blackness) / 100.0
61
+
62
+ sum = whiteness + blackness
63
+ if sum > 1
64
+ gray = whiteness / sum
65
+ SRGB.convert(dest,
66
+ gray,
67
+ gray,
68
+ gray,
69
+ alpha,
70
+ missing_hue:)
71
+ else
72
+ f = lambda do |n|
73
+ k = (n + hue) % 12
74
+ 0.5 - ([-1, [k - 3, 9 - k, 1].min].max / 2.0)
75
+ end
76
+
77
+ factor = 1 - sum
78
+ SRGB.convert(dest,
79
+ (f.call(0) * factor) + whiteness,
80
+ (f.call(8) * factor) + whiteness,
81
+ (f.call(4) * factor) + whiteness,
82
+ alpha,
83
+ missing_hue:)
84
+ end
85
+ end
86
+ end
87
+
88
+ private_constant :Hwb
89
+
90
+ HWB = Hwb.new
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ module Space
7
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/lab.dart
8
+ class Lab
9
+ include Space
10
+
11
+ def bounded?
12
+ false
13
+ end
14
+
15
+ def initialize
16
+ super('lab', [
17
+ LinearChannel.new('lightness', 0, 100, lower_clamped: true, upper_clamped: true).freeze,
18
+ LinearChannel.new('a', -125, 125).freeze,
19
+ LinearChannel.new('b', -125, 125).freeze
20
+ ].freeze)
21
+ end
22
+
23
+ def convert(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParameterName
24
+ missing_chroma: false, missing_hue: false)
25
+ if missing_chroma && missing_hue
26
+ a = nil
27
+ b = nil
28
+ elsif a.nil? && b.nil?
29
+ missing_chroma = true
30
+ missing_hue = true
31
+ end
32
+
33
+ case dest
34
+ when LAB
35
+ powerless_ab = lightness.nil? || FuzzyMath.equals?(lightness, 0)
36
+ Color.send(
37
+ :_for_space,
38
+ dest,
39
+ lightness,
40
+ a.nil? || powerless_ab ? nil : a,
41
+ b.nil? || powerless_ab ? nil : b,
42
+ alpha
43
+ )
44
+ when LCH
45
+ Utils.lab_to_lch(dest, lightness, a, b, alpha)
46
+ else
47
+ missing_lightness = lightness.nil?
48
+ lightness = 0 if missing_lightness
49
+
50
+ f1 = (lightness + 16) / 116.0
51
+
52
+ XYZ_D50.convert(
53
+ dest,
54
+ _convert_f_to_x_or_z(((a.nil? ? 0 : a) / 500.0) + f1) * Conversions::D50[0],
55
+ (if lightness > Utils::LAB_KAPPA * Utils::LAB_EPSILON
56
+ (((lightness + 16) / 116.0)**3)
57
+ else
58
+ lightness / Utils::LAB_KAPPA
59
+ end) * Conversions::D50[1],
60
+ _convert_f_to_x_or_z(f1 - ((b.nil? ? 0 : b) / 200.0)) * Conversions::D50[2],
61
+ alpha,
62
+ missing_lightness:,
63
+ missing_chroma:,
64
+ missing_hue:,
65
+ missing_a: a.nil?,
66
+ missing_b: b.nil?
67
+ )
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def _convert_f_to_x_or_z(component)
74
+ cubed = component**3
75
+ cubed > Utils::LAB_EPSILON ? cubed : ((116 * component) - 16) / Utils::LAB_KAPPA
76
+ end
77
+ end
78
+
79
+ private_constant :Lab
80
+
81
+ LAB = Lab.new
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ module Space
7
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/lch.dart
8
+ class Lch
9
+ include Space
10
+
11
+ def bounded?
12
+ false
13
+ end
14
+
15
+ def polar?
16
+ true
17
+ end
18
+
19
+ def initialize
20
+ super('lch', [
21
+ LinearChannel.new('lightness', 0, 100, lower_clamped: true, upper_clamped: true).freeze,
22
+ LinearChannel.new('chroma', 0, 150, lower_clamped: true).freeze,
23
+ Utils::HUE_CHANNEL
24
+ ].freeze)
25
+ end
26
+
27
+ def convert(dest, lightness, chroma, hue, alpha)
28
+ missing_chroma = chroma.nil?
29
+ missing_hue = hue.nil?
30
+
31
+ chroma = 0 if missing_chroma
32
+ hue = 0 if missing_hue
33
+
34
+ hue_radians = hue * Math::PI / 180
35
+ LAB.convert(
36
+ dest,
37
+ lightness,
38
+ chroma * Math.cos(hue_radians),
39
+ chroma * Math.sin(hue_radians),
40
+ alpha,
41
+ missing_chroma:,
42
+ missing_hue:
43
+ )
44
+ end
45
+ end
46
+
47
+ private_constant :Lch
48
+
49
+ LCH = Lch.new
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,146 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ module Value
5
+ class Color
6
+ module Space
7
+ # @see https://github.com/sass/dart-sass/blob/main/lib/src/value/color/space/lms.dart
8
+ class Lms
9
+ include Space
10
+
11
+ def bounded?
12
+ false
13
+ end
14
+
15
+ def initialize
16
+ super('lms', [
17
+ LinearChannel.new('long', 0, 1).freeze,
18
+ LinearChannel.new('medium', 0, 1).freeze,
19
+ LinearChannel.new('short', 0, 1).freeze
20
+ ].freeze)
21
+ end
22
+
23
+ def convert(dest, long, medium, short, alpha,
24
+ missing_lightness: false,
25
+ missing_chroma: false,
26
+ missing_hue: false,
27
+ missing_a: false,
28
+ missing_b: false)
29
+ if missing_a && missing_b
30
+ missing_chroma = true
31
+ missing_hue = true
32
+ elsif missing_chroma && missing_hue
33
+ missing_a = true
34
+ missing_b = true
35
+ end
36
+
37
+ if (missing_lightness && missing_chroma && missing_hue) || (long.nil? && medium.nil? && short.nil?)
38
+ return Color.send(:_for_space,
39
+ dest,
40
+ nil,
41
+ nil,
42
+ nil,
43
+ alpha)
44
+ end
45
+
46
+ case dest
47
+ when OKLAB
48
+ long_scaled = Math.cbrt(long.nil? ? 0 : long)
49
+ medium_scaled = Math.cbrt(medium.nil? ? 0 : medium)
50
+ short_scaled = Math.cbrt(short.nil? ? 0 : short)
51
+
52
+ Color.send(
53
+ :_for_space,
54
+ dest,
55
+ unless missing_lightness
56
+ (Conversions::LMS_TO_OKLAB[0] * long_scaled) +
57
+ (Conversions::LMS_TO_OKLAB[1] * medium_scaled) +
58
+ (Conversions::LMS_TO_OKLAB[2] * short_scaled)
59
+ end,
60
+ unless missing_a
61
+ (Conversions::LMS_TO_OKLAB[3] * long_scaled) +
62
+ (Conversions::LMS_TO_OKLAB[4] * medium_scaled) +
63
+ (Conversions::LMS_TO_OKLAB[5] * short_scaled)
64
+ end,
65
+ unless missing_b
66
+ (Conversions::LMS_TO_OKLAB[6] * long_scaled) +
67
+ (Conversions::LMS_TO_OKLAB[7] * medium_scaled) +
68
+ (Conversions::LMS_TO_OKLAB[8] * short_scaled)
69
+ end,
70
+ alpha
71
+ )
72
+ when OKLCH
73
+ long_scaled = Math.cbrt(long.nil? ? 0 : long)
74
+ medium_scaled = Math.cbrt(medium.nil? ? 0 : medium)
75
+ short_scaled = Math.cbrt(short.nil? ? 0 : short)
76
+
77
+ Utils.lab_to_lch(
78
+ dest,
79
+ unless missing_lightness
80
+ (Conversions::LMS_TO_OKLAB[0] * long_scaled) +
81
+ (Conversions::LMS_TO_OKLAB[1] * medium_scaled) +
82
+ (Conversions::LMS_TO_OKLAB[2] * short_scaled)
83
+ end,
84
+ unless missing_a
85
+ (Conversions::LMS_TO_OKLAB[3] * long_scaled) +
86
+ (Conversions::LMS_TO_OKLAB[4] * medium_scaled) +
87
+ (Conversions::LMS_TO_OKLAB[5] * short_scaled)
88
+ end,
89
+ unless missing_b
90
+ (Conversions::LMS_TO_OKLAB[6] * long_scaled) +
91
+ (Conversions::LMS_TO_OKLAB[7] * medium_scaled) +
92
+ (Conversions::LMS_TO_OKLAB[8] * short_scaled)
93
+ end,
94
+ alpha
95
+ )
96
+ else
97
+ convert_linear(dest, long, medium, short, alpha,
98
+ missing_lightness:,
99
+ missing_chroma:,
100
+ missing_hue:,
101
+ missing_a:,
102
+ missing_b:)
103
+ end
104
+ end
105
+
106
+ def to_linear(channel)
107
+ channel
108
+ end
109
+
110
+ def from_linear(channel)
111
+ channel
112
+ end
113
+
114
+ private
115
+
116
+ def transformation_matrix(dest)
117
+ case dest
118
+ when A98_RGB
119
+ Conversions::LMS_TO_LINEAR_A98_RGB
120
+ when DISPLAY_P3, DISPLAY_P3_LINEAR
121
+ Conversions::LMS_TO_LINEAR_DISPLAY_P3
122
+ when PROPHOTO_RGB
123
+ Conversions::LMS_TO_LINEAR_PROPHOTO_RGB
124
+ when REC2020
125
+ Conversions::LMS_TO_LINEAR_REC2020
126
+ when RGB, SRGB, SRGB_LINEAR
127
+ Conversions::LMS_TO_LINEAR_SRGB
128
+ when XYZ_D50
129
+ Conversions::LMS_TO_XYZ_D50
130
+ when XYZ_D65
131
+ Conversions::LMS_TO_XYZ_D65
132
+ else
133
+ super
134
+ end
135
+ end
136
+ end
137
+
138
+ private_constant :Lms
139
+
140
+ LMS = Lms.new
141
+
142
+ private_constant :LMS
143
+ end
144
+ end
145
+ end
146
+ end