sass-embedded 1.79.3-x86-linux-musl → 1.79.4-x86-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/sass +1 -9
- data/ext/sass/cli.rb +7 -0
- data/ext/sass/dart-sass/src/sass.snapshot +0 -0
- data/lib/sass/compiler/connection.rb +1 -9
- data/lib/sass/compiler/host/protofier.rb +16 -55
- data/lib/sass/elf.rb +4 -4
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/value/color/channel.rb +79 -0
- data/lib/sass/value/color/conversions.rb +464 -0
- data/lib/sass/value/color/gamut_map_method/clip.rb +45 -0
- data/lib/sass/value/color/gamut_map_method/local_minde.rb +94 -0
- data/lib/sass/value/color/gamut_map_method.rb +45 -0
- data/lib/sass/value/color/interpolation_method.rb +51 -0
- data/lib/sass/value/color/space/a98_rgb.rb +57 -0
- data/lib/sass/value/color/space/display_p3.rb +57 -0
- data/lib/sass/value/color/space/hsl.rb +65 -0
- data/lib/sass/value/color/space/hwb.rb +70 -0
- data/lib/sass/value/color/space/lab.rb +77 -0
- data/lib/sass/value/color/space/lch.rb +53 -0
- data/lib/sass/value/color/space/lms.rb +129 -0
- data/lib/sass/value/color/space/oklab.rb +66 -0
- data/lib/sass/value/color/space/oklch.rb +54 -0
- data/lib/sass/value/color/space/prophoto_rgb.rb +59 -0
- data/lib/sass/value/color/space/rec2020.rb +69 -0
- data/lib/sass/value/color/space/rgb.rb +52 -0
- data/lib/sass/value/color/space/srgb.rb +141 -0
- data/lib/sass/value/color/space/srgb_linear.rb +72 -0
- data/lib/sass/value/color/space/utils.rb +86 -0
- data/lib/sass/value/color/space/xyz_d50.rb +100 -0
- data/lib/sass/value/color/space/xyz_d65.rb +57 -0
- data/lib/sass/value/color/space.rb +198 -0
- data/lib/sass/value/color.rb +537 -162
- data/lib/sass/value/fuzzy_math.rb +30 -3
- data/lib/sass/value/string.rb +1 -1
- metadata +29 -5
@@ -0,0 +1,198 @@
|
|
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/space.dart
|
7
|
+
module Space
|
8
|
+
# @return [::String]
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
# @return [Array<ColorChannel>]
|
12
|
+
attr_reader :channels
|
13
|
+
|
14
|
+
# @return [::Boolean]
|
15
|
+
def bounded?
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [::Boolean]
|
20
|
+
def legacy?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [::Boolean]
|
25
|
+
def polar?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
# @param name [::String]
|
30
|
+
# @param channels [Array<ColorChannel>]
|
31
|
+
def initialize(name, channels)
|
32
|
+
@name = name
|
33
|
+
@channels = channels
|
34
|
+
end
|
35
|
+
|
36
|
+
class << self
|
37
|
+
# @param name [::String]
|
38
|
+
# @param argument_name [::String]
|
39
|
+
# @return [Space]
|
40
|
+
def from_name(name, argument_name = nil)
|
41
|
+
case name.downcase
|
42
|
+
when 'rgb'
|
43
|
+
RGB
|
44
|
+
when 'hwb'
|
45
|
+
HWB
|
46
|
+
when 'hsl'
|
47
|
+
HSL
|
48
|
+
when 'srgb'
|
49
|
+
SRGB
|
50
|
+
when 'srgb-linear'
|
51
|
+
SRGB_LINEAR
|
52
|
+
when 'display-p3'
|
53
|
+
DISPLAY_P3
|
54
|
+
when 'a98-rgb'
|
55
|
+
A98_RGB
|
56
|
+
when 'prophoto-rgb'
|
57
|
+
PROPHOTO_RGB
|
58
|
+
when 'rec2020'
|
59
|
+
REC2020
|
60
|
+
when 'xyz', 'xyz-d65'
|
61
|
+
XYZ_D65
|
62
|
+
when 'xyz-d50'
|
63
|
+
XYZ_D50
|
64
|
+
when 'lab'
|
65
|
+
LAB
|
66
|
+
when 'lch'
|
67
|
+
LCH
|
68
|
+
when 'oklab'
|
69
|
+
OKLAB
|
70
|
+
when 'oklch'
|
71
|
+
OKLCH
|
72
|
+
else
|
73
|
+
raise Sass::ScriptError.new("Unknown color space \"#{name}\".", argument_name)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# @param dest [Space]
|
79
|
+
# @param channel0 [Numeric]
|
80
|
+
# @param channel1 [Numeric]
|
81
|
+
# @param channel2 [Numeric]
|
82
|
+
# @param alpha [Numeric]
|
83
|
+
# @return [Color]
|
84
|
+
def convert(dest, channel0, channel1, channel2, alpha)
|
85
|
+
convert_linear(dest, channel0, channel1, channel2, alpha)
|
86
|
+
end
|
87
|
+
|
88
|
+
protected
|
89
|
+
|
90
|
+
def convert_linear(dest, red, green, blue, alpha,
|
91
|
+
missing_lightness: false,
|
92
|
+
missing_chroma: false,
|
93
|
+
missing_hue: false,
|
94
|
+
missing_a: false,
|
95
|
+
missing_b: false)
|
96
|
+
linear_dest = case dest
|
97
|
+
when HSL, HWB
|
98
|
+
SRGB
|
99
|
+
when LAB, LCH
|
100
|
+
XYZ_D50
|
101
|
+
when OKLAB, OKLCH
|
102
|
+
LMS
|
103
|
+
else
|
104
|
+
dest
|
105
|
+
end
|
106
|
+
if linear_dest == self
|
107
|
+
transformed_red = red
|
108
|
+
transformed_green = green
|
109
|
+
transformed_blue = blue
|
110
|
+
else
|
111
|
+
linear_red = to_linear(red.nil? ? 0 : red)
|
112
|
+
linear_green = to_linear(green.nil? ? 0 : green)
|
113
|
+
linear_blue = to_linear(blue.nil? ? 0 : blue)
|
114
|
+
matrix = transformation_matrix(linear_dest)
|
115
|
+
|
116
|
+
# (matrix * [linear_red, linear_green, linear_blue]).map(linear_dest.from_linear)
|
117
|
+
transformed_red = linear_dest.from_linear((matrix[0] * linear_red) +
|
118
|
+
(matrix[1] * linear_green) +
|
119
|
+
(matrix[2] * linear_blue))
|
120
|
+
transformed_green = linear_dest.from_linear((matrix[3] * linear_red) +
|
121
|
+
(matrix[4] * linear_green) +
|
122
|
+
(matrix[5] * linear_blue))
|
123
|
+
transformed_blue = linear_dest.from_linear((matrix[6] * linear_red) +
|
124
|
+
(matrix[7] * linear_green) +
|
125
|
+
(matrix[8] * linear_blue))
|
126
|
+
end
|
127
|
+
|
128
|
+
case dest
|
129
|
+
when HSL, HWB
|
130
|
+
SRGB.convert(dest, transformed_red, transformed_green, transformed_blue, alpha,
|
131
|
+
missing_lightness:,
|
132
|
+
missing_chroma:,
|
133
|
+
missing_hue:)
|
134
|
+
when LAB, LCH
|
135
|
+
XYZ_D50.convert(dest, transformed_red, transformed_green, transformed_blue, alpha,
|
136
|
+
missing_lightness:,
|
137
|
+
missing_chroma:,
|
138
|
+
missing_hue:,
|
139
|
+
missing_a:,
|
140
|
+
missing_b:)
|
141
|
+
when OKLAB, OKLCH
|
142
|
+
LMS.convert(dest, transformed_red, transformed_green, transformed_blue, alpha,
|
143
|
+
missing_lightness:,
|
144
|
+
missing_chroma:,
|
145
|
+
missing_hue:,
|
146
|
+
missing_a:,
|
147
|
+
missing_b:)
|
148
|
+
else
|
149
|
+
Color.send(:_for_space,
|
150
|
+
dest,
|
151
|
+
red.nil? ? nil : transformed_red,
|
152
|
+
green.nil? ? nil : transformed_green,
|
153
|
+
blue.nil? ? nil : transformed_blue,
|
154
|
+
alpha)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# @param channel [Numeric]
|
159
|
+
# @return [Numeric]
|
160
|
+
def to_linear(channel)
|
161
|
+
raise NotImplementedError, "[BUG] Color space #{name} doesn't support linear conversions."
|
162
|
+
end
|
163
|
+
|
164
|
+
# @param channel [Numeric]
|
165
|
+
# @return [Numeric]
|
166
|
+
def from_linear(channel)
|
167
|
+
raise NotImplementedError, "[BUG] Color space #{name} doesn't support linear conversions."
|
168
|
+
end
|
169
|
+
|
170
|
+
# @param dest [Space]
|
171
|
+
# @return [Array<Numeric>]
|
172
|
+
def transformation_matrix(dest)
|
173
|
+
raise NotImplementedError, "[BUG] Color space conversion from #{name} to #{dest.name} not implemented."
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
private_constant :Space
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
require_relative 'space/utils'
|
183
|
+
require_relative 'space/a98_rgb'
|
184
|
+
require_relative 'space/display_p3'
|
185
|
+
require_relative 'space/hsl'
|
186
|
+
require_relative 'space/hwb'
|
187
|
+
require_relative 'space/lab'
|
188
|
+
require_relative 'space/lch'
|
189
|
+
require_relative 'space/lms'
|
190
|
+
require_relative 'space/oklab'
|
191
|
+
require_relative 'space/oklch'
|
192
|
+
require_relative 'space/prophoto_rgb'
|
193
|
+
require_relative 'space/rec2020'
|
194
|
+
require_relative 'space/rgb'
|
195
|
+
require_relative 'space/srgb'
|
196
|
+
require_relative 'space/srgb_linear'
|
197
|
+
require_relative 'space/xyz_d50'
|
198
|
+
require_relative 'space/xyz_d65'
|