sai 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +25 -4
- data/docs/USAGE.md +9 -16
- data/lib/sai/ansi.rb +40 -0
- data/lib/sai/conversion/rgb/color_space.rb +2 -2
- data/lib/sai/decorator/delegator.rb +79 -0
- data/lib/sai/decorator/named_colors.rb +38 -744
- data/lib/sai/decorator.rb +2 -3
- data/lib/sai/registry.rb +134 -0
- data/lib/sai.rb +28 -765
- data/sig/sai/ansi.rbs +21 -0
- data/sig/sai/decorator/delegator.rbs +95 -0
- data/sig/sai/decorator/named_colors.rbs +30 -1460
- data/sig/sai/decorator.rbs +2 -3
- data/sig/sai/{named_colors.rbs → registry.rbs} +31 -52
- data/sig/sai.rbs +14 -1519
- metadata +8 -8
- data/lib/sai/decorator/delegation.rb +0 -85
- data/lib/sai/named_colors.rb +0 -522
- data/sig/sai/decorator/delegation.rbs +0 -47
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Sai (彩) - meaning 'coloring' or 'paint' in Japanese - is a powerful and intuitive system for managing color output in command-line applications. Drawing inspiration from traditional Japanese artistic techniques, Sai brings vibrancy and harmony to terminal interfaces through its sophisticated color management.
|
@@ -38,14 +38,14 @@ files:
|
|
38
38
|
- lib/sai/conversion/rgb/color_transformer.rb
|
39
39
|
- lib/sai/decorator.rb
|
40
40
|
- lib/sai/decorator/color_manipulations.rb
|
41
|
-
- lib/sai/decorator/
|
41
|
+
- lib/sai/decorator/delegator.rb
|
42
42
|
- lib/sai/decorator/gradients.rb
|
43
43
|
- lib/sai/decorator/hex_colors.rb
|
44
44
|
- lib/sai/decorator/named_colors.rb
|
45
45
|
- lib/sai/decorator/named_styles.rb
|
46
46
|
- lib/sai/decorator/rgb_colors.rb
|
47
47
|
- lib/sai/mode_selector.rb
|
48
|
-
- lib/sai/
|
48
|
+
- lib/sai/registry.rb
|
49
49
|
- lib/sai/support.rb
|
50
50
|
- lib/sai/terminal/capabilities.rb
|
51
51
|
- lib/sai/terminal/color_mode.rb
|
@@ -64,14 +64,14 @@ files:
|
|
64
64
|
- sig/sai/conversion/rgb/color_transformer.rbs
|
65
65
|
- sig/sai/decorator.rbs
|
66
66
|
- sig/sai/decorator/color_manipulations.rbs
|
67
|
-
- sig/sai/decorator/
|
67
|
+
- sig/sai/decorator/delegator.rbs
|
68
68
|
- sig/sai/decorator/gradients.rbs
|
69
69
|
- sig/sai/decorator/hex_colors.rbs
|
70
70
|
- sig/sai/decorator/named_colors.rbs
|
71
71
|
- sig/sai/decorator/named_styles.rbs
|
72
72
|
- sig/sai/decorator/rgb_colors.rbs
|
73
73
|
- sig/sai/mode_selector.rbs
|
74
|
-
- sig/sai/
|
74
|
+
- sig/sai/registry.rbs
|
75
75
|
- sig/sai/support.rbs
|
76
76
|
- sig/sai/terminal/capabilities.rbs
|
77
77
|
- sig/sai/terminal/color_mode.rbs
|
@@ -80,10 +80,10 @@ licenses:
|
|
80
80
|
- MIT
|
81
81
|
metadata:
|
82
82
|
bug_tracker_uri: https://github.com/aaronmallen/sai/issues
|
83
|
-
changelog_uri: https://github.com/aaronmallen/sai/releases/tag/0.
|
83
|
+
changelog_uri: https://github.com/aaronmallen/sai/releases/tag/0.4.0
|
84
84
|
homepage_uri: https://github.com/aaronmallen/sai
|
85
85
|
rubygems_mfa_required: 'true'
|
86
|
-
source_code_uri: https://github.com/aaronmallen/sai/tree/0.
|
86
|
+
source_code_uri: https://github.com/aaronmallen/sai/tree/0.4.0
|
87
87
|
post_install_message:
|
88
88
|
rdoc_options: []
|
89
89
|
require_paths:
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sai/decorator'
|
4
|
-
require 'sai/decorator/color_manipulations'
|
5
|
-
require 'sai/decorator/gradients'
|
6
|
-
require 'sai/decorator/hex_colors'
|
7
|
-
require 'sai/decorator/named_colors'
|
8
|
-
require 'sai/decorator/named_styles'
|
9
|
-
require 'sai/decorator/rgb_colors'
|
10
|
-
|
11
|
-
module Sai
|
12
|
-
class Decorator
|
13
|
-
# Delegates all methods from the Decorator class and its component modules
|
14
|
-
#
|
15
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
16
|
-
# @since 0.3.1
|
17
|
-
#
|
18
|
-
# @api private
|
19
|
-
module Delegation
|
20
|
-
# The list of component modules to delegate methods from
|
21
|
-
#
|
22
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
23
|
-
# @since 0.3.1
|
24
|
-
#
|
25
|
-
# @api private
|
26
|
-
#
|
27
|
-
# @return [Array<Symbol>] the list of component modules
|
28
|
-
COMPONENT_MODULES = %i[
|
29
|
-
ColorManipulations
|
30
|
-
Gradients
|
31
|
-
HexColors
|
32
|
-
NamedColors
|
33
|
-
NamedStyles
|
34
|
-
RGBColors
|
35
|
-
].freeze #: Array[Symbol]
|
36
|
-
private_constant :COMPONENT_MODULES
|
37
|
-
|
38
|
-
class << self
|
39
|
-
# Install delegated methods on the given class or module
|
40
|
-
#
|
41
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
42
|
-
# @since 0.3.1
|
43
|
-
#
|
44
|
-
# @api private
|
45
|
-
#
|
46
|
-
# @param klass [Class, Module] the class or module to install the methods on
|
47
|
-
#
|
48
|
-
# @return [void]
|
49
|
-
# @rbs (Class | Module) -> void
|
50
|
-
def install(klass)
|
51
|
-
ignored_methods = %i[apply call decorate encode]
|
52
|
-
methods = collect_delegatable_methods.reject { |m| ignored_methods.include?(m) }
|
53
|
-
|
54
|
-
methods.each do |method|
|
55
|
-
klass.undef_method(method) if klass.method_defined?(method)
|
56
|
-
klass.define_method(method) do |*args, **kwargs|
|
57
|
-
Decorator.new(mode: Sai.mode.auto).public_send(method, *args, **kwargs)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
# Collect all methods from the Decorator class and its component modules
|
65
|
-
#
|
66
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
67
|
-
# @since 0.3.1
|
68
|
-
#
|
69
|
-
# @api private
|
70
|
-
#
|
71
|
-
# @return [Array<Symbol>] the list of methods to delegate
|
72
|
-
# @rbs () -> Array[Symbol]
|
73
|
-
def collect_delegatable_methods
|
74
|
-
methods = Decorator.instance_methods(false)
|
75
|
-
|
76
|
-
COMPONENT_MODULES.each do |mod|
|
77
|
-
methods.concat(Decorator.const_get(mod).instance_methods(false))
|
78
|
-
end
|
79
|
-
|
80
|
-
methods.uniq
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
data/lib/sai/named_colors.rb
DELETED
@@ -1,522 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sai/conversion/rgb'
|
4
|
-
|
5
|
-
module Sai
|
6
|
-
# A collection of named colors and their RGB values
|
7
|
-
#
|
8
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
9
|
-
# @since 0.3.1
|
10
|
-
#
|
11
|
-
# @api private
|
12
|
-
module NamedColors
|
13
|
-
# Standard ANSI color names and their RGB values
|
14
|
-
#
|
15
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
16
|
-
# @since 0.3.1
|
17
|
-
#
|
18
|
-
# @api private
|
19
|
-
#
|
20
|
-
# @return [Hash{Symbol => Array<Integer>}] the color names and RGB values
|
21
|
-
ANSI = {
|
22
|
-
black: [0, 0, 0],
|
23
|
-
red: [205, 0, 0],
|
24
|
-
green: [0, 205, 0],
|
25
|
-
yellow: [205, 205, 0],
|
26
|
-
blue: [0, 0, 238],
|
27
|
-
magenta: [205, 0, 205],
|
28
|
-
cyan: [0, 205, 205],
|
29
|
-
white: [229, 229, 229],
|
30
|
-
bright_black: [127, 127, 127],
|
31
|
-
bright_red: [255, 0, 0],
|
32
|
-
bright_green: [0, 255, 0],
|
33
|
-
bright_yellow: [255, 255, 0],
|
34
|
-
bright_blue: [92, 92, 255],
|
35
|
-
bright_magenta: [255, 0, 255],
|
36
|
-
bright_cyan: [0, 255, 255],
|
37
|
-
bright_white: [255, 255, 255]
|
38
|
-
}.freeze # Hash[Symbol, Array[Integer]]
|
39
|
-
|
40
|
-
# CSS color names and their RGB values
|
41
|
-
#
|
42
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
43
|
-
# @since 0.3.1
|
44
|
-
#
|
45
|
-
# @api private
|
46
|
-
#
|
47
|
-
# @return [Hash{Symbol => Array<Integer>}] the color names and RGB values
|
48
|
-
CSS = {
|
49
|
-
alice_blue: [240, 248, 255],
|
50
|
-
antique_white: [250, 235, 215],
|
51
|
-
aqua: [0, 255, 255],
|
52
|
-
aquamarine: [127, 255, 212],
|
53
|
-
azure: [240, 255, 255],
|
54
|
-
beige: [245, 245, 220],
|
55
|
-
bisque: [255, 228, 196],
|
56
|
-
blanched_almond: [255, 235, 205],
|
57
|
-
brown: [165, 42, 42],
|
58
|
-
burly_wood: [222, 184, 135],
|
59
|
-
chartreuse: [127, 255, 0],
|
60
|
-
chocolate: [210, 105, 30],
|
61
|
-
coral: [255, 127, 80],
|
62
|
-
cornsilk: [255, 248, 220],
|
63
|
-
crimson: [220, 20, 60],
|
64
|
-
dark_gray: [169, 169, 169],
|
65
|
-
dark_olive_green: [85, 107, 47],
|
66
|
-
dark_orchid: [153, 50, 204],
|
67
|
-
dark_salmon: [233, 150, 122],
|
68
|
-
dark_slate_blue: [72, 61, 139],
|
69
|
-
dark_slate_gray: [47, 79, 79],
|
70
|
-
deep_pink: [255, 20, 147],
|
71
|
-
deep_sky_blue: [0, 191, 255],
|
72
|
-
dim_gray: [105, 105, 105],
|
73
|
-
dodger_blue: [30, 144, 255],
|
74
|
-
firebrick: [178, 34, 34],
|
75
|
-
floral_white: [255, 250, 240],
|
76
|
-
forest_green: [34, 139, 34],
|
77
|
-
fuchsia: [255, 0, 255],
|
78
|
-
gainsboro: [220, 220, 220],
|
79
|
-
ghost_white: [248, 248, 255],
|
80
|
-
gold: [255, 215, 0],
|
81
|
-
goldenrod: [218, 165, 32],
|
82
|
-
gray: [128, 128, 128],
|
83
|
-
honeydew: [240, 255, 240],
|
84
|
-
indigo: [75, 0, 130],
|
85
|
-
ivory: [255, 255, 240],
|
86
|
-
khaki: [240, 230, 140],
|
87
|
-
lavender: [230, 230, 250],
|
88
|
-
lavender_blush: [255, 240, 245],
|
89
|
-
lawn_green: [124, 252, 0],
|
90
|
-
lemon_chiffon: [255, 250, 205],
|
91
|
-
light_blue: [173, 216, 230],
|
92
|
-
light_cyan: [224, 255, 255],
|
93
|
-
light_goldenrod_yellow: [250, 250, 210],
|
94
|
-
light_gray: [211, 211, 211],
|
95
|
-
light_pink: [255, 182, 193],
|
96
|
-
light_salmon: [255, 160, 122],
|
97
|
-
light_sea_green: [32, 178, 170],
|
98
|
-
light_sky_blue: [135, 206, 250],
|
99
|
-
light_slate_gray: [119, 136, 153],
|
100
|
-
light_yellow: [255, 255, 224],
|
101
|
-
lime: [0, 255, 0],
|
102
|
-
lime_green: [50, 205, 50],
|
103
|
-
linen: [250, 240, 230],
|
104
|
-
maroon: [128, 0, 0],
|
105
|
-
medium_aquamarine: [102, 205, 170],
|
106
|
-
medium_blue: [0, 0, 205],
|
107
|
-
medium_sea_green: [60, 179, 113],
|
108
|
-
medium_slate_blue: [123, 104, 238],
|
109
|
-
midnight_blue: [25, 25, 112],
|
110
|
-
mint_cream: [245, 255, 250],
|
111
|
-
misty_rose: [255, 228, 225],
|
112
|
-
moccasin: [255, 228, 181],
|
113
|
-
navajo_white: [255, 222, 173],
|
114
|
-
navy: [0, 0, 128],
|
115
|
-
old_lace: [253, 245, 230],
|
116
|
-
olive: [128, 128, 0],
|
117
|
-
olive_drab: [107, 142, 35],
|
118
|
-
orange: [255, 165, 0],
|
119
|
-
orange_red: [255, 69, 0],
|
120
|
-
pale_goldenrod: [238, 232, 170],
|
121
|
-
pale_green: [152, 251, 152],
|
122
|
-
pale_turquoise: [175, 238, 238],
|
123
|
-
pale_violet_red: [219, 112, 147],
|
124
|
-
papaya_whip: [255, 239, 213],
|
125
|
-
peach_puff: [255, 218, 185],
|
126
|
-
peru: [205, 133, 63],
|
127
|
-
pink: [255, 192, 203],
|
128
|
-
plum: [221, 160, 221],
|
129
|
-
powder_blue: [176, 224, 230],
|
130
|
-
royal_blue: [65, 105, 225],
|
131
|
-
saddle_brown: [139, 69, 19],
|
132
|
-
salmon: [250, 128, 114],
|
133
|
-
sea_green: [46, 139, 87],
|
134
|
-
sea_shell: [255, 245, 238],
|
135
|
-
sienna: [160, 82, 45],
|
136
|
-
silver: [192, 192, 192],
|
137
|
-
sky_blue: [135, 206, 235],
|
138
|
-
slate_blue: [106, 90, 205],
|
139
|
-
slate_gray: [112, 128, 144],
|
140
|
-
snow: [255, 250, 250],
|
141
|
-
spring_green: [0, 255, 127],
|
142
|
-
teal: [0, 128, 128],
|
143
|
-
thistle: [216, 191, 216],
|
144
|
-
tomato: [255, 99, 71],
|
145
|
-
turquoise: [64, 224, 208],
|
146
|
-
wheat: [245, 222, 179],
|
147
|
-
white_smoke: [245, 245, 245],
|
148
|
-
yellow_green: [154, 205, 50]
|
149
|
-
}.freeze #: Hash[Symbol, Array[Integer]]
|
150
|
-
|
151
|
-
# XTERM color names and their RGB values
|
152
|
-
#
|
153
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
154
|
-
# @since 0.3.1
|
155
|
-
#
|
156
|
-
# @api private
|
157
|
-
#
|
158
|
-
# @return [Hash{Symbol => Array<Integer>}] the color names and RGB values
|
159
|
-
# rubocop:disable Naming/VariableNumber
|
160
|
-
XTERM = {
|
161
|
-
aqua_system: [0, 255, 255],
|
162
|
-
aquamarine1: [95, 255, 215],
|
163
|
-
aquamarine1_122: [135, 255, 215],
|
164
|
-
aquamarine3: [95, 215, 175],
|
165
|
-
black_system: [0, 0, 0],
|
166
|
-
blue1: [0, 0, 255],
|
167
|
-
blue_system: [0, 0, 255],
|
168
|
-
blue_violet: [95, 0, 255],
|
169
|
-
blue3: [0, 0, 175],
|
170
|
-
blue3_20: [0, 0, 215],
|
171
|
-
cadet_blue: [95, 175, 135],
|
172
|
-
cadet_blue_73: [95, 175, 175],
|
173
|
-
chartreuse1: [135, 255, 0],
|
174
|
-
chartreuse2: [95, 255, 0],
|
175
|
-
chartreuse2_112: [135, 215, 0],
|
176
|
-
chartreuse3: [95, 175, 0],
|
177
|
-
chartreuse3_76: [95, 215, 0],
|
178
|
-
chartreuse4: [95, 135, 0],
|
179
|
-
cornflower_blue: [95, 135, 255],
|
180
|
-
cornsilk1: [255, 255, 215],
|
181
|
-
cyan1: [0, 255, 255],
|
182
|
-
cyan2: [0, 255, 215],
|
183
|
-
cyan3: [0, 215, 175],
|
184
|
-
dark_blue: [0, 0, 135],
|
185
|
-
dark_cyan: [0, 175, 135],
|
186
|
-
dark_goldenrod: [175, 135, 0],
|
187
|
-
dark_green: [0, 95, 0],
|
188
|
-
dark_khaki: [175, 175, 95],
|
189
|
-
dark_magenta: [135, 0, 135],
|
190
|
-
dark_magenta_91: [135, 0, 175],
|
191
|
-
dark_olive_green1: [215, 255, 95],
|
192
|
-
dark_olive_green1_192: [215, 255, 135],
|
193
|
-
dark_olive_green2: [175, 255, 95],
|
194
|
-
dark_olive_green3: [135, 175, 95],
|
195
|
-
dark_olive_green3_113: [135, 215, 95],
|
196
|
-
dark_olive_green3_149: [175, 215, 95],
|
197
|
-
dark_orange: [255, 135, 0],
|
198
|
-
dark_orange3: [175, 95, 0],
|
199
|
-
dark_orange3_166: [215, 95, 0],
|
200
|
-
dark_red: [95, 0, 0],
|
201
|
-
dark_red_88: [135, 0, 0],
|
202
|
-
dark_sea_green: [135, 175, 135],
|
203
|
-
dark_sea_green1: [175, 255, 215],
|
204
|
-
dark_sea_green1_193: [215, 255, 175],
|
205
|
-
dark_sea_green2: [175, 215, 175],
|
206
|
-
dark_sea_green2_157: [175, 255, 175],
|
207
|
-
dark_sea_green3: [135, 215, 175],
|
208
|
-
dark_sea_green3_150: [175, 215, 135],
|
209
|
-
dark_sea_green4: [95, 135, 95],
|
210
|
-
dark_sea_green4_71: [95, 175, 95],
|
211
|
-
dark_slate_gray1: [135, 255, 255],
|
212
|
-
dark_slate_gray2: [95, 255, 255],
|
213
|
-
dark_slate_gray3: [135, 215, 215],
|
214
|
-
dark_turquoise: [0, 215, 215],
|
215
|
-
dark_violet: [135, 0, 215],
|
216
|
-
dark_violet_128: [175, 0, 215],
|
217
|
-
deep_pink1: [255, 0, 135],
|
218
|
-
deep_pink1_199: [255, 0, 175],
|
219
|
-
deep_pink2: [255, 0, 95],
|
220
|
-
deep_pink3: [215, 0, 95],
|
221
|
-
deep_pink3_162: [215, 0, 135],
|
222
|
-
deep_pink4: [95, 0, 95],
|
223
|
-
deep_pink4_89: [135, 0, 95],
|
224
|
-
deep_pink4_125: [175, 0, 95],
|
225
|
-
deep_sky_blue1: [0, 175, 255],
|
226
|
-
deep_sky_blue2: [0, 175, 215],
|
227
|
-
deep_sky_blue3: [0, 135, 175],
|
228
|
-
deep_sky_blue3_32: [0, 135, 215],
|
229
|
-
deep_sky_blue4: [0, 95, 95],
|
230
|
-
deep_sky_blue4_24: [0, 95, 135],
|
231
|
-
deep_sky_blue4_25: [0, 95, 175],
|
232
|
-
dodger_blue1: [0, 135, 255],
|
233
|
-
dodger_blue2: [0, 95, 255],
|
234
|
-
dodger_blue3: [0, 95, 215],
|
235
|
-
fuchsia_system: [255, 0, 255],
|
236
|
-
gold1: [255, 215, 0],
|
237
|
-
gold3: [175, 175, 0],
|
238
|
-
gold3_178: [215, 175, 0],
|
239
|
-
green1: [0, 255, 0],
|
240
|
-
green3: [0, 175, 0],
|
241
|
-
green3_40: [0, 215, 0],
|
242
|
-
green4: [0, 135, 0],
|
243
|
-
green_system: [0, 128, 0],
|
244
|
-
green_yellow: [175, 255, 0],
|
245
|
-
grey0: [0, 0, 0],
|
246
|
-
grey100: [255, 255, 255],
|
247
|
-
grey11: [28, 28, 28],
|
248
|
-
grey15: [38, 38, 38],
|
249
|
-
grey19: [48, 48, 48],
|
250
|
-
grey23: [58, 58, 58],
|
251
|
-
grey27: [68, 68, 68],
|
252
|
-
grey3: [8, 8, 8],
|
253
|
-
grey30: [78, 78, 78],
|
254
|
-
grey35: [88, 88, 88],
|
255
|
-
grey37: [95, 95, 95],
|
256
|
-
grey39: [98, 98, 98],
|
257
|
-
grey42: [108, 108, 108],
|
258
|
-
grey46: [118, 118, 118],
|
259
|
-
grey50: [128, 128, 128],
|
260
|
-
grey53: [135, 135, 135],
|
261
|
-
grey54: [138, 138, 138],
|
262
|
-
grey58: [148, 148, 148],
|
263
|
-
grey62: [158, 158, 158],
|
264
|
-
grey66: [168, 168, 168],
|
265
|
-
grey7: [18, 18, 18],
|
266
|
-
grey70: [178, 178, 178],
|
267
|
-
grey74: [188, 188, 188],
|
268
|
-
grey78: [198, 198, 198],
|
269
|
-
grey82: [208, 208, 208],
|
270
|
-
grey84: [215, 215, 215],
|
271
|
-
grey85: [218, 218, 218],
|
272
|
-
grey89: [228, 228, 228],
|
273
|
-
grey93: [238, 238, 238],
|
274
|
-
grey_system: [128, 128, 128],
|
275
|
-
honeydew2: [215, 255, 215],
|
276
|
-
hot_pink: [255, 95, 175],
|
277
|
-
hot_pink_206: [255, 95, 215],
|
278
|
-
hot_pink2: [215, 95, 175],
|
279
|
-
hot_pink3: [175, 95, 135],
|
280
|
-
hot_pink3_168: [215, 95, 135],
|
281
|
-
indian_red: [175, 95, 95],
|
282
|
-
indian_red_167: [215, 95, 95],
|
283
|
-
indian_red1: [255, 95, 95],
|
284
|
-
indian_red1_204: [255, 95, 135],
|
285
|
-
khaki1: [255, 255, 135],
|
286
|
-
khaki3: [215, 215, 95],
|
287
|
-
light_coral: [255, 135, 135],
|
288
|
-
light_cyan1: [215, 255, 255],
|
289
|
-
light_cyan3: [175, 215, 215],
|
290
|
-
light_goldenrod1: [255, 255, 95],
|
291
|
-
light_goldenrod2: [255, 215, 135],
|
292
|
-
light_goldenrod2_221: [255, 215, 95],
|
293
|
-
light_goldenrod3: [215, 175, 95],
|
294
|
-
light_green: [135, 255, 95],
|
295
|
-
light_green_120: [135, 255, 135],
|
296
|
-
light_pink1: [255, 175, 175],
|
297
|
-
light_pink3: [215, 135, 135],
|
298
|
-
light_pink4: [135, 95, 95],
|
299
|
-
light_salmon1: [255, 175, 135],
|
300
|
-
light_salmon3: [175, 135, 95],
|
301
|
-
light_salmon3_173: [215, 135, 95],
|
302
|
-
light_sky_blue1: [175, 215, 255],
|
303
|
-
light_sky_blue3: [135, 175, 175],
|
304
|
-
light_sky_blue3_110: [135, 175, 215],
|
305
|
-
light_slate_blue: [135, 135, 255],
|
306
|
-
light_slate_grey: [135, 135, 175],
|
307
|
-
light_steel_blue: [175, 175, 255],
|
308
|
-
light_steel_blue1: [215, 215, 255],
|
309
|
-
light_steel_blue3: [175, 175, 215],
|
310
|
-
lime_system: [0, 255, 0],
|
311
|
-
magenta1: [255, 0, 255],
|
312
|
-
magenta2: [215, 0, 255],
|
313
|
-
magenta2_200: [255, 0, 215],
|
314
|
-
magenta3: [175, 0, 175],
|
315
|
-
magenta3_163: [215, 0, 175],
|
316
|
-
magenta3_164: [215, 0, 215],
|
317
|
-
maroon_system: [128, 0, 0],
|
318
|
-
medium_orchid: [175, 95, 215],
|
319
|
-
medium_orchid1: [215, 95, 255],
|
320
|
-
medium_orchid1_207: [255, 95, 255],
|
321
|
-
medium_orchid3: [175, 95, 175],
|
322
|
-
medium_purple: [135, 135, 215],
|
323
|
-
medium_purple1: [175, 135, 255],
|
324
|
-
medium_purple2: [175, 95, 255],
|
325
|
-
medium_purple2_140: [175, 135, 215],
|
326
|
-
medium_purple3: [135, 95, 175],
|
327
|
-
medium_purple3_98: [135, 95, 215],
|
328
|
-
medium_purple4: [95, 95, 135],
|
329
|
-
medium_spring_green: [0, 255, 175],
|
330
|
-
medium_turquoise: [95, 215, 215],
|
331
|
-
medium_violet_red: [175, 0, 135],
|
332
|
-
misty_rose1: [255, 215, 215],
|
333
|
-
misty_rose3: [215, 175, 175],
|
334
|
-
navy_blue: [0, 0, 95],
|
335
|
-
navy_system: [0, 0, 128],
|
336
|
-
navajo_white1: [255, 215, 175],
|
337
|
-
navajo_white3: [175, 175, 135],
|
338
|
-
olive_system: [128, 128, 0],
|
339
|
-
orange1: [255, 175, 0],
|
340
|
-
orange3: [215, 135, 0],
|
341
|
-
orange4: [95, 95, 0],
|
342
|
-
orange4_94: [135, 95, 0],
|
343
|
-
orange_red1: [255, 95, 0],
|
344
|
-
orchid: [215, 95, 215],
|
345
|
-
orchid1: [255, 135, 255],
|
346
|
-
orchid2: [255, 135, 215],
|
347
|
-
pale_green1: [135, 255, 175],
|
348
|
-
pale_green1_156: [175, 255, 135],
|
349
|
-
pale_green3: [95, 215, 95],
|
350
|
-
pale_green3_114: [135, 215, 135],
|
351
|
-
pale_turquoise1: [175, 255, 255],
|
352
|
-
pale_turquoise4: [95, 135, 135],
|
353
|
-
pale_violet_red1: [255, 135, 175],
|
354
|
-
pink1: [255, 175, 215],
|
355
|
-
pink3: [215, 135, 175],
|
356
|
-
plum1: [255, 175, 255],
|
357
|
-
plum2: [215, 175, 255],
|
358
|
-
plum3: [215, 135, 215],
|
359
|
-
plum4: [135, 95, 135],
|
360
|
-
purple: [135, 0, 255],
|
361
|
-
purple_129: [175, 0, 255],
|
362
|
-
purple3: [95, 0, 215],
|
363
|
-
purple4: [95, 0, 135],
|
364
|
-
purple4_55: [95, 0, 175],
|
365
|
-
purple_system: [128, 0, 128],
|
366
|
-
red1: [255, 0, 0],
|
367
|
-
red3: [175, 0, 0],
|
368
|
-
red3_160: [215, 0, 0],
|
369
|
-
red_system: [255, 0, 0],
|
370
|
-
rosy_brown: [175, 135, 135],
|
371
|
-
royal_blue1: [95, 95, 255],
|
372
|
-
salmon1: [255, 135, 95],
|
373
|
-
sandy_brown: [255, 175, 95],
|
374
|
-
silver_system: [192, 192, 192],
|
375
|
-
sky_blue1: [135, 215, 255],
|
376
|
-
sky_blue2: [135, 175, 255],
|
377
|
-
sky_blue3: [95, 175, 215],
|
378
|
-
slate_blue1: [135, 95, 255],
|
379
|
-
slate_blue3: [95, 95, 175],
|
380
|
-
slate_blue3_62: [95, 95, 215],
|
381
|
-
spring_green1: [0, 255, 135],
|
382
|
-
spring_green2: [0, 215, 135],
|
383
|
-
spring_green2_47: [0, 255, 95],
|
384
|
-
spring_green3: [0, 175, 95],
|
385
|
-
spring_green3_41: [0, 215, 95],
|
386
|
-
spring_green4: [0, 135, 95],
|
387
|
-
steel_blue: [95, 135, 175],
|
388
|
-
steel_blue1: [95, 175, 255],
|
389
|
-
steel_blue1_81: [95, 215, 255],
|
390
|
-
steel_blue3: [95, 135, 215],
|
391
|
-
tan: [215, 175, 135],
|
392
|
-
teal_system: [0, 128, 128],
|
393
|
-
thistle1: [255, 215, 255],
|
394
|
-
thistle3: [215, 175, 215],
|
395
|
-
turquoise2: [0, 215, 255],
|
396
|
-
turquoise4: [0, 135, 135],
|
397
|
-
violet: [215, 135, 255],
|
398
|
-
wheat1: [255, 255, 175],
|
399
|
-
wheat4: [135, 135, 95],
|
400
|
-
white_system: [255, 255, 255],
|
401
|
-
yellow1: [255, 255, 0],
|
402
|
-
yellow2: [215, 255, 0],
|
403
|
-
yellow3: [175, 215, 0],
|
404
|
-
yellow3_184: [215, 215, 0],
|
405
|
-
yellow4: [135, 135, 0],
|
406
|
-
yellow4_106: [135, 175, 0],
|
407
|
-
yellow_system: [255, 255, 0]
|
408
|
-
}.freeze #: Hash[Symbol, Array[Integer]]
|
409
|
-
# rubocop:enable Naming/VariableNumber
|
410
|
-
|
411
|
-
class << self
|
412
|
-
# Look up an RGB value by color name
|
413
|
-
#
|
414
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
415
|
-
# @since 0.3.1
|
416
|
-
#
|
417
|
-
# @api private
|
418
|
-
#
|
419
|
-
# @param name [String, Symbol] the color name
|
420
|
-
#
|
421
|
-
# @return [Array<Integer>] the RGB value
|
422
|
-
# @rbs (String | Symbol name) -> Array[Integer]?
|
423
|
-
def [](name)
|
424
|
-
registry[name.to_sym]
|
425
|
-
end
|
426
|
-
|
427
|
-
# Get a list of all color names
|
428
|
-
#
|
429
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
430
|
-
# @since 0.3.1
|
431
|
-
#
|
432
|
-
# @api private
|
433
|
-
#
|
434
|
-
# @return [Array<Symbol>] the color names
|
435
|
-
def names
|
436
|
-
@names ||= registry.keys.uniq.sort
|
437
|
-
end
|
438
|
-
|
439
|
-
# Register a named color with an RGB or Hexadecimal value
|
440
|
-
#
|
441
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
442
|
-
# @since 0.3.2
|
443
|
-
#
|
444
|
-
# @api private
|
445
|
-
#
|
446
|
-
# @param name [String, Symbol] the name of the color being registered
|
447
|
-
# @param rgb_or_hex [Array<Integer>, String] the RGB or Hexadecimal value of the color
|
448
|
-
#
|
449
|
-
# @return [Boolean] `true` if the color was registered
|
450
|
-
# @rbs (String | Symbol name, Array[Integer] | String rgb_or_hex) -> void
|
451
|
-
def register(name, rgb_or_hex)
|
452
|
-
key = name.to_s.downcase.to_sym
|
453
|
-
provision_color(key, rgb_or_hex)
|
454
|
-
install_color(key)
|
455
|
-
true
|
456
|
-
end
|
457
|
-
|
458
|
-
private
|
459
|
-
|
460
|
-
# Install the color methods onto {Sai} and {Sai::Decorator}
|
461
|
-
#
|
462
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
463
|
-
# @since 0.3.2
|
464
|
-
#
|
465
|
-
# @api private
|
466
|
-
#
|
467
|
-
# @param name [Symbol] the name of the color to install
|
468
|
-
#
|
469
|
-
# @return [void]
|
470
|
-
# @rbs (Symbol name) -> void
|
471
|
-
def install_color(name)
|
472
|
-
Sai::Decorator::NamedColors.install(name)
|
473
|
-
Sai::Decorator::Delegation.install(Sai)
|
474
|
-
end
|
475
|
-
|
476
|
-
# Provision a color for the registry
|
477
|
-
#
|
478
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
479
|
-
# @since 0.3.2
|
480
|
-
#
|
481
|
-
# @api private
|
482
|
-
#
|
483
|
-
# @param name [Symbol] the name of the color to register
|
484
|
-
# @param rgb_or_hex [Array<Integer>, String] the RGB or Hexadecimal value of the color
|
485
|
-
#
|
486
|
-
# @return [void]
|
487
|
-
# @rbs (Symbol name, Array[Integer] | String rgb_or_hex) -> void
|
488
|
-
def provision_color(name, rgb_or_hex)
|
489
|
-
rgb = Conversion::RGB.resolve(rgb_or_hex)
|
490
|
-
registry[name] = rgb
|
491
|
-
@names = nil
|
492
|
-
end
|
493
|
-
|
494
|
-
# The Sai named colors registry
|
495
|
-
#
|
496
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
497
|
-
# @since 0.3.2
|
498
|
-
#
|
499
|
-
# @api private
|
500
|
-
#
|
501
|
-
# @return [Hash{Symbol => Array<Integer>}] the named colors registry
|
502
|
-
def registry
|
503
|
-
thread_lock.synchronize do
|
504
|
-
@registry ||= CSS.merge(XTERM).merge(ANSI)
|
505
|
-
end
|
506
|
-
end
|
507
|
-
|
508
|
-
# A Mutex for thread safety
|
509
|
-
#
|
510
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
511
|
-
# @since 0.3.2
|
512
|
-
#
|
513
|
-
# @api private
|
514
|
-
#
|
515
|
-
# @return [Mutex] the thread lock
|
516
|
-
# @rbs () -> Mutex
|
517
|
-
def thread_lock
|
518
|
-
@thread_lock ||= Mutex.new
|
519
|
-
end
|
520
|
-
end
|
521
|
-
end
|
522
|
-
end
|