unmagic-color 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +79 -0
- data/README.md +209 -36
- data/data/css.jsonc +150 -0
- data/data/css.txt +148 -0
- data/data/x11.jsonc +660 -0
- data/data/x11.txt +753 -0
- data/lib/unmagic/color/console/banner.rb +55 -0
- data/lib/unmagic/color/console/card.rb +165 -0
- data/lib/unmagic/color/console/help.rb +70 -0
- data/lib/unmagic/color/console/highlighter.rb +114 -0
- data/lib/unmagic/color/gradient/base.rb +252 -0
- data/lib/unmagic/color/gradient/bitmap.rb +91 -0
- data/lib/unmagic/color/gradient/stop.rb +48 -0
- data/lib/unmagic/color/gradient.rb +154 -0
- data/lib/unmagic/color/harmony.rb +293 -0
- data/lib/unmagic/color/hsl/gradient/linear.rb +152 -0
- data/lib/unmagic/color/hsl.rb +136 -21
- data/lib/unmagic/color/oklch/gradient/linear.rb +151 -0
- data/lib/unmagic/color/oklch.rb +115 -12
- data/lib/unmagic/color/rgb/ansi.rb +227 -0
- data/lib/unmagic/color/rgb/gradient/linear.rb +165 -0
- data/lib/unmagic/color/rgb/hex.rb +20 -8
- data/lib/unmagic/color/rgb/named.rb +213 -43
- data/lib/unmagic/color/rgb.rb +325 -22
- data/lib/unmagic/color/units/degrees.rb +233 -0
- data/lib/unmagic/color/units/direction.rb +206 -0
- data/lib/unmagic/color/util/percentage.rb +150 -22
- data/lib/unmagic/color/version.rb +8 -0
- data/lib/unmagic/color.rb +95 -0
- metadata +23 -3
- data/data/rgb.txt +0 -164
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 385638e771dedbaff1485e3d8d45d18e632b4210b6d6d781916ef34358c09bd6
|
|
4
|
+
data.tar.gz: a34aa8373606265ada813caae4a495c006a9a71f3cfa8ec37c759ceb0e6f3818
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f484d35f71337bf9055569537a97337ea4cba6ddadf74774e73d93d6f1567a5b2934312e76635755fb6ca52aae1317ca9e47055d376e836f89d0ec8298af4d3
|
|
7
|
+
data.tar.gz: c99cd2ec04a304a7ef707449c21503238e6db4dee39ab31b6b73e731ab2e26e8a7d0bbf12b9a46d214f58cc354d00707bf40fd69ce0abab6e380f99205219de1
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.2.0] - 2026-01-05
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
#### Color Harmonies
|
|
15
|
+
- `complementary` - returns the opposite color on the color wheel (180° shift)
|
|
16
|
+
- `analogous(angle: 30)` - returns two adjacent colors at ±angle degrees
|
|
17
|
+
- `triadic` - returns two colors equally spaced at +120° and +240°
|
|
18
|
+
- `split_complementary(angle: 30)` - returns two colors flanking the complement
|
|
19
|
+
- `tetradic_square` - returns three colors at +90°, +180°, +270°
|
|
20
|
+
- `tetradic_rectangle(angle: 60)` - returns three colors forming a rectangle on the wheel
|
|
21
|
+
|
|
22
|
+
#### Color Variations
|
|
23
|
+
- `monochromatic(steps: 5)` - generates colors with varying lightness
|
|
24
|
+
- `shades(steps: 5, amount: 0.5)` - generates progressively darker colors
|
|
25
|
+
- `tints(steps: 5, amount: 0.5)` - generates progressively lighter colors
|
|
26
|
+
- `tones(steps: 5, amount: 0.5)` - generates progressively desaturated colors
|
|
27
|
+
|
|
28
|
+
#### Gradients
|
|
29
|
+
- `Unmagic::Color::Gradient.linear` - create gradients with automatic color space detection
|
|
30
|
+
- `Unmagic::Color::RGB::Gradient::Linear` - RGB color space gradients
|
|
31
|
+
- `Unmagic::Color::HSL::Gradient::Linear` - HSL color space gradients (smoother hue transitions)
|
|
32
|
+
- `Unmagic::Color::OKLCH::Gradient::Linear` - OKLCH gradients (perceptually uniform)
|
|
33
|
+
- Support for gradient directions: keywords (`to right`), angles (`45deg`), and from/to syntax
|
|
34
|
+
- 2D gradient rasterization with `width` and `height` parameters
|
|
35
|
+
- Explicit color stop positions (like CSS `linear-gradient`)
|
|
36
|
+
|
|
37
|
+
#### Alpha Channel
|
|
38
|
+
- Alpha channel support for RGB, HSL, and OKLCH colors
|
|
39
|
+
- Parse alpha from CSS color functions: `rgba()`, `hsla()`, `oklch()` with alpha
|
|
40
|
+
- `Alpha` class with CSS ratio output (`to_css` returns 0.0-1.0)
|
|
41
|
+
|
|
42
|
+
#### ANSI Terminal Colors
|
|
43
|
+
- ANSI escape code parsing (3/4-bit, 256-color, and 24-bit true color)
|
|
44
|
+
- `to_ansi` method with `mode:` parameter (`:truecolor`, `:palette256`, `:palette16`)
|
|
45
|
+
- Truecolor (24-bit) output by default for accurate color reproduction
|
|
46
|
+
- Support for both foreground and background layers
|
|
47
|
+
- Color swatches in `pretty_print` output
|
|
48
|
+
|
|
49
|
+
#### Console Tools
|
|
50
|
+
- `Unmagic::Color::Console::Card` - render color profile cards with harmonies and variations
|
|
51
|
+
- `Unmagic::Color::Console::Banner` - gradient ASCII art banner
|
|
52
|
+
- `Unmagic::Color::Console::Help` - syntax-highlighted help text
|
|
53
|
+
- `Unmagic::Color::Console::Highlighter` - Ruby syntax highlighting with customizable colors
|
|
54
|
+
|
|
55
|
+
#### Other
|
|
56
|
+
- Full X11 color database (658 colors) with lazy loading
|
|
57
|
+
- JSON storage for color databases (faster loading, ~54KB for X11)
|
|
58
|
+
- `build` class method with positional arguments: `RGB.build(255, 87, 51)`
|
|
59
|
+
- Improved percentage parsing with fraction notation support (`1/2` = 50%)
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
- Default ANSI output mode changed from `:palette16` to `:truecolor` for better color accuracy
|
|
63
|
+
- Color databases are now stored as JSON for faster parsing
|
|
64
|
+
|
|
65
|
+
## [0.1.0] - 2026-01-01
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
- Initial release
|
|
69
|
+
- RGB, HSL, and OKLCH color space support
|
|
70
|
+
- Color parsing from hex, CSS functions, and X11 named colors
|
|
71
|
+
- Color manipulation (lighten, darken, blend)
|
|
72
|
+
- Color space conversions
|
|
73
|
+
- Deterministic color generation from strings
|
|
74
|
+
- Luminance calculations and light/dark detection
|
|
75
|
+
- HSL color progressions for palette generation
|
|
76
|
+
- Multiple hash functions for string-to-color derivation
|
|
77
|
+
|
|
78
|
+
[0.2.0]: https://github.com/unreasonable-magic/unmagic-color/releases/tag/v0.2.0
|
|
79
|
+
[0.1.0]: https://github.com/unreasonable-magic/unmagic-color/releases/tag/v0.1.0
|
data/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# unmagic-color
|
|
2
|
+
|
|
3
|
+

|
|
2
4
|
|
|
3
5
|
A comprehensive Ruby color manipulation library with support for RGB, HSL, and OKLCH color spaces. Parse, convert, and manipulate colors with an intuitive API.
|
|
4
6
|
|
|
@@ -22,38 +24,6 @@ Or install it yourself as:
|
|
|
22
24
|
gem install unmagic-color
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
## Features
|
|
26
|
-
|
|
27
|
-
- **Multiple Color Spaces**: RGB, HSL, and OKLCH support
|
|
28
|
-
- **Flexible Parsing**: Parse colors from hex, CSS format strings, named colors, or component values
|
|
29
|
-
- **Named Colors**: Support for [X11 color names](https://en.wikipedia.org/wiki/X11_color_names) (red, blue, goldenrod, etc.)
|
|
30
|
-
- **Color Conversions**: Seamlessly convert between color spaces
|
|
31
|
-
- **Color Manipulation**: Lighten, darken, and blend colors
|
|
32
|
-
- **Deterministic Generation**: Generate consistent colors from strings or seeds
|
|
33
|
-
- **Luminance Calculation**: Determine if colors are light or dark
|
|
34
|
-
- **Color Progressions**: Create color scales and palettes
|
|
35
|
-
|
|
36
|
-
## Quick Start
|
|
37
|
-
|
|
38
|
-
```ruby
|
|
39
|
-
require 'unmagic/color'
|
|
40
|
-
|
|
41
|
-
# Parse a color
|
|
42
|
-
color = Unmagic::Color.parse("#FF5733")
|
|
43
|
-
|
|
44
|
-
# Convert to different color spaces
|
|
45
|
-
hsl = color.to_hsl
|
|
46
|
-
oklch = color.to_oklch
|
|
47
|
-
|
|
48
|
-
# Manipulate colors
|
|
49
|
-
lighter = color.lighten(0.2)
|
|
50
|
-
darker = color.darken(0.1)
|
|
51
|
-
|
|
52
|
-
# Check luminance
|
|
53
|
-
color.light? # => false
|
|
54
|
-
color.dark? # => true
|
|
55
|
-
```
|
|
56
|
-
|
|
57
27
|
## Usage Examples
|
|
58
28
|
|
|
59
29
|
### Parsing Colors
|
|
@@ -75,15 +45,71 @@ color = Unmagic::Color::HSL.new(hue: 9, saturation: 100, lightness: 60)
|
|
|
75
45
|
color = Unmagic::Color.parse("oklch(0.65 0.15 30)")
|
|
76
46
|
color = Unmagic::Color::OKLCH.new(lightness: 0.65, chroma: 0.15, hue: 30)
|
|
77
47
|
|
|
78
|
-
# From
|
|
48
|
+
# From named colors (X11 is the default and CSS/W3C databases)
|
|
79
49
|
color = Unmagic::Color.parse("goldenrod")
|
|
80
50
|
color = Unmagic::Color["red"]
|
|
81
51
|
|
|
52
|
+
# Pass db name as prefix for specific lookup:
|
|
53
|
+
color = Unmagic::Color.parse("css:red")
|
|
54
|
+
color = Unmagic::Color.parse("w3c:gray") # w3c is alias for css
|
|
55
|
+
color = Unmagic::Color.parse("x11:red")
|
|
56
|
+
|
|
82
57
|
# Named colors are case-insensitive and whitespace-tolerant
|
|
83
58
|
color = Unmagic::Color.parse("Golden Rod") # Same as "goldenrod"
|
|
84
59
|
color = Unmagic::Color.parse("DARK SLATE BLUE") # Same as "darkslateblue"
|
|
85
60
|
```
|
|
86
61
|
|
|
62
|
+
**Named Color Databases:**
|
|
63
|
+
- **X11**: 658 colors, ~54 KB in memory (lazy-loaded)
|
|
64
|
+
- **CSS/W3C**: 148 colors, ~13 KB in memory (lazy-loaded)
|
|
65
|
+
|
|
66
|
+
Databases are only loaded into memory when first accessed, with sub-millisecond load times.
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
# From ANSI escape codes
|
|
70
|
+
color = Unmagic::Color.parse("31") # Red (standard ANSI)
|
|
71
|
+
color = Unmagic::Color.parse("38;5;196") # Red (256-color palette)
|
|
72
|
+
color = Unmagic::Color.parse("38;2;255;0;0") # Red (24-bit true color)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Terminal Colors (ANSI)
|
|
76
|
+
|
|
77
|
+
Generate ANSI escape codes for colorful terminal output:
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
# Convert any color to ANSI
|
|
81
|
+
color = Unmagic::Color.parse("goldenrod")
|
|
82
|
+
puts "\x1b[#{color.to_ansi}mHello World!\x1b[0m"
|
|
83
|
+
|
|
84
|
+
# Foreground colors (default)
|
|
85
|
+
red = Unmagic::Color.parse("#ff0000")
|
|
86
|
+
puts "\x1b[#{red.to_ansi}mRed text\x1b[0m"
|
|
87
|
+
|
|
88
|
+
# Background colors
|
|
89
|
+
blue = Unmagic::Color.parse("#0000ff")
|
|
90
|
+
puts "\x1b[#{blue.to_ansi(layer: :background)}mBlue background\x1b[0m"
|
|
91
|
+
|
|
92
|
+
# Default mode is 24-bit true color
|
|
93
|
+
Unmagic::Color.parse("red").to_ansi # => "38;2;255;0;0"
|
|
94
|
+
Unmagic::Color.parse("css:green").to_ansi # => "38;2;0;128;0"
|
|
95
|
+
|
|
96
|
+
# Named colors can use standard codes with palette16 mode
|
|
97
|
+
Unmagic::Color.parse("red").to_ansi(mode: :palette16) # => "91"
|
|
98
|
+
Unmagic::Color.parse("green").to_ansi(mode: :palette16) # => "92"
|
|
99
|
+
|
|
100
|
+
# Custom colors also use 24-bit true color by default
|
|
101
|
+
Unmagic::Color.parse("#6496c8").to_ansi # => "38;2;100;150;200"
|
|
102
|
+
|
|
103
|
+
# Parse ANSI codes back to colors
|
|
104
|
+
color = Unmagic::Color.parse("38;2;100;150;200")
|
|
105
|
+
color.to_hex # => "#6496c8"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Supported ANSI formats:**
|
|
109
|
+
- **3/4-bit colors**: `30-37` (foreground), `40-47` (background), `90-97` (bright foreground), `100-107` (bright background)
|
|
110
|
+
- **256-color palette**: `38;5;N` (foreground), `48;5;N` (background) where N is 0-255
|
|
111
|
+
- **24-bit true color**: `38;2;R;G;B` (foreground), `48;2;R;G;B` (background)
|
|
112
|
+
|
|
87
113
|
### Converting Between Color Spaces
|
|
88
114
|
|
|
89
115
|
```ruby
|
|
@@ -91,7 +117,7 @@ rgb = Unmagic::Color.parse("#FF5733")
|
|
|
91
117
|
|
|
92
118
|
# Convert to HSL
|
|
93
119
|
hsl = rgb.to_hsl
|
|
94
|
-
puts hsl.hue.to_f # =>
|
|
120
|
+
puts hsl.hue.to_f # => 11.0
|
|
95
121
|
puts hsl.saturation.to_f # => 100.0
|
|
96
122
|
puts hsl.lightness.to_f # => 60.0
|
|
97
123
|
|
|
@@ -100,7 +126,7 @@ oklch = rgb.to_oklch
|
|
|
100
126
|
|
|
101
127
|
# Convert back to hex
|
|
102
128
|
hex = hsl.to_rgb.to_hex
|
|
103
|
-
puts hex # => "#
|
|
129
|
+
puts hex # => "#ff5833"
|
|
104
130
|
```
|
|
105
131
|
|
|
106
132
|
### Color Manipulation
|
|
@@ -125,6 +151,78 @@ else
|
|
|
125
151
|
end
|
|
126
152
|
```
|
|
127
153
|
|
|
154
|
+
### Color Harmonies
|
|
155
|
+
|
|
156
|
+
Generate color palettes based on color theory relationships:
|
|
157
|
+
|
|
158
|
+
```ruby
|
|
159
|
+
color = Unmagic::Color.parse("#FF5733")
|
|
160
|
+
|
|
161
|
+
# Complementary - opposite on the color wheel (180°)
|
|
162
|
+
complement = color.complementary
|
|
163
|
+
# => Single color opposite on the wheel
|
|
164
|
+
|
|
165
|
+
# Analogous - adjacent colors (default ±30°)
|
|
166
|
+
analogous = color.analogous
|
|
167
|
+
# => [color at -30°, color at +30°]
|
|
168
|
+
analogous = color.analogous(angle: 15) # Custom angle
|
|
169
|
+
|
|
170
|
+
# Triadic - three colors equally spaced (120° apart)
|
|
171
|
+
triadic = color.triadic
|
|
172
|
+
# => [color at +120°, color at +240°]
|
|
173
|
+
|
|
174
|
+
# Split Complementary - complement's neighbors (default 180° ±30°)
|
|
175
|
+
split = color.split_complementary
|
|
176
|
+
# => [color at 150°, color at 210°]
|
|
177
|
+
split = color.split_complementary(angle: 45) # Custom split
|
|
178
|
+
|
|
179
|
+
# Tetradic Square - four colors equally spaced (90° apart)
|
|
180
|
+
tetradic = color.tetradic_square
|
|
181
|
+
# => [color at +90°, color at +180°, color at +270°]
|
|
182
|
+
|
|
183
|
+
# Tetradic Rectangle - two complementary pairs (default 60°)
|
|
184
|
+
tetradic = color.tetradic_rectangle
|
|
185
|
+
# => [color at +60°, color at +180°, color at +240°]
|
|
186
|
+
tetradic = color.tetradic_rectangle(angle: 30) # Custom angle
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Color Variations
|
|
190
|
+
|
|
191
|
+

|
|
192
|
+
|
|
193
|
+
Generate shades, tints, tones, and monochromatic palettes:
|
|
194
|
+
|
|
195
|
+
```ruby
|
|
196
|
+
color = Unmagic::Color.parse("#3366CC")
|
|
197
|
+
|
|
198
|
+
# Monochromatic - same hue with varying lightness
|
|
199
|
+
mono = color.monochromatic(steps: 5)
|
|
200
|
+
# => Array of 5 colors from dark to light
|
|
201
|
+
|
|
202
|
+
# Shades - progressively darker (mixed with black)
|
|
203
|
+
shades = color.shades(steps: 5)
|
|
204
|
+
shades = color.shades(steps: 5, amount: 0.8) # Darker range
|
|
205
|
+
|
|
206
|
+
# Tints - progressively lighter (mixed with white)
|
|
207
|
+
tints = color.tints(steps: 5)
|
|
208
|
+
tints = color.tints(steps: 5, amount: 0.8) # Lighter range
|
|
209
|
+
|
|
210
|
+
# Tones - progressively desaturated (mixed with gray)
|
|
211
|
+
tones = color.tones(steps: 5)
|
|
212
|
+
tones = color.tones(steps: 5, amount: 0.8) # More muted range
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
All harmony and variation methods preserve the original color space:
|
|
216
|
+
|
|
217
|
+
```ruby
|
|
218
|
+
hsl = Unmagic::Color::HSL.new(hue: 200, saturation: 80, lightness: 50)
|
|
219
|
+
hsl.complementary # => HSL color
|
|
220
|
+
hsl.shades(steps: 3) # => Array of HSL colors
|
|
221
|
+
|
|
222
|
+
rgb = Unmagic::Color.parse("#FF5733")
|
|
223
|
+
rgb.analogous # => Array of RGB colors
|
|
224
|
+
```
|
|
225
|
+
|
|
128
226
|
### HSL-Specific Features
|
|
129
227
|
|
|
130
228
|
```ruby
|
|
@@ -231,6 +329,81 @@ color.dark? # => true
|
|
|
231
329
|
text_color = color.light? ? "#000000" : "#FFFFFF"
|
|
232
330
|
```
|
|
233
331
|
|
|
332
|
+
### Gradients
|
|
333
|
+
|
|
334
|
+
Create smooth color transitions with gradients in RGB, HSL, or OKLCH color spaces:
|
|
335
|
+
|
|
336
|
+
```ruby
|
|
337
|
+
# Simple gradient - auto-detects color space
|
|
338
|
+
gradient = Unmagic::Color::Gradient.linear(["#FF0000", "#0000FF"])
|
|
339
|
+
bitmap = gradient.rasterize(width: 10)
|
|
340
|
+
|
|
341
|
+
# Access the colors
|
|
342
|
+
colors = bitmap.pixels[0] # Array of 10 colors from red to blue
|
|
343
|
+
colors.map(&:to_hex)
|
|
344
|
+
# => ["#ff0000", "#e60019", "#cc0033", ..., "#0000ff"]
|
|
345
|
+
|
|
346
|
+
# Create gradients with multiple stops
|
|
347
|
+
gradient = Unmagic::Color::Gradient.linear([
|
|
348
|
+
"#FF0000", # Red at start (0%)
|
|
349
|
+
"#00FF00", # Green at middle (50%)
|
|
350
|
+
"#0000FF" # Blue at end (100%)
|
|
351
|
+
])
|
|
352
|
+
bitmap = gradient.rasterize(width: 20)
|
|
353
|
+
|
|
354
|
+
# Use explicit positions (like CSS linear-gradient)
|
|
355
|
+
gradient = Unmagic::Color::Gradient.linear([
|
|
356
|
+
["#FF0000", 0.0], # Red at start
|
|
357
|
+
["#FFFF00", 0.3], # Yellow at 30%
|
|
358
|
+
"#00FF00", # Green auto-balances at 65%
|
|
359
|
+
["#0000FF", 1.0] # Blue at end
|
|
360
|
+
])
|
|
361
|
+
|
|
362
|
+
# Specify gradient direction
|
|
363
|
+
gradient = Unmagic::Color::Gradient.linear(
|
|
364
|
+
["#FF0000", "#0000FF"],
|
|
365
|
+
direction: "to right"
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
# Use angle directions
|
|
369
|
+
gradient = Unmagic::Color::Gradient.linear(
|
|
370
|
+
["#FF0000", "#0000FF"],
|
|
371
|
+
direction: "45deg" # or just 45
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
# 2D gradients with width and height
|
|
375
|
+
gradient = Unmagic::Color::Gradient.linear(
|
|
376
|
+
["#FF0000", "#0000FF"],
|
|
377
|
+
direction: "to bottom right"
|
|
378
|
+
)
|
|
379
|
+
bitmap = gradient.rasterize(width: 100, height: 100)
|
|
380
|
+
|
|
381
|
+
# Access individual pixels
|
|
382
|
+
color = bitmap.at(50, 50) # Get color at x=50, y=50
|
|
383
|
+
|
|
384
|
+
# Choose color space for different effects
|
|
385
|
+
# RGB gradients - direct color component interpolation
|
|
386
|
+
rgb_gradient = Unmagic::Color::RGB::Gradient::Linear.build(["#FF0000", "#0000FF"])
|
|
387
|
+
|
|
388
|
+
# HSL gradients - smoother transitions through the color wheel
|
|
389
|
+
hsl_gradient = Unmagic::Color::HSL::Gradient::Linear.build([
|
|
390
|
+
"hsl(0, 100%, 50%)", # Red
|
|
391
|
+
"hsl(240, 100%, 50%)" # Blue
|
|
392
|
+
])
|
|
393
|
+
|
|
394
|
+
# OKLCH gradients - perceptually uniform transitions
|
|
395
|
+
oklch_gradient = Unmagic::Color::OKLCH::Gradient::Linear.build([
|
|
396
|
+
"oklch(0.5 0.15 30)", # Orange
|
|
397
|
+
"oklch(0.7 0.15 240)" # Blue
|
|
398
|
+
])
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
**Supported direction formats:**
|
|
402
|
+
- Keywords: `"to top"`, `"to right"`, `"to bottom left"`, etc.
|
|
403
|
+
- From/to: `"from left to right"`, `"from bottom to top"`
|
|
404
|
+
- Angles: `"45deg"`, `"90deg"`, or numeric values like `45`, `90`
|
|
405
|
+
- Direction objects: `Unmagic::Color::Units::Degrees::Direction::LEFT_TO_RIGHT`
|
|
406
|
+
|
|
234
407
|
## Color Spaces
|
|
235
408
|
|
|
236
409
|
### RGB (Red, Green, Blue)
|
data/data/css.jsonc
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
{
|
|
2
|
+
"black": 0, // #000000
|
|
3
|
+
"silver": 12632256, // #c0c0c0
|
|
4
|
+
"gray": 8421504, // #808080
|
|
5
|
+
"white": 16777215, // #ffffff
|
|
6
|
+
"maroon": 8388608, // #800000
|
|
7
|
+
"red": 16711680, // #ff0000
|
|
8
|
+
"purple": 8388736, // #800080
|
|
9
|
+
"fuchsia": 16711935, // #ff00ff
|
|
10
|
+
"green": 32768, // #008000
|
|
11
|
+
"lime": 65280, // #00ff00
|
|
12
|
+
"olive": 8421376, // #808000
|
|
13
|
+
"yellow": 16776960, // #ffff00
|
|
14
|
+
"navy": 128, // #000080
|
|
15
|
+
"blue": 255, // #0000ff
|
|
16
|
+
"teal": 32896, // #008080
|
|
17
|
+
"aqua": 65535, // #00ffff
|
|
18
|
+
"aliceblue": 15792383, // #f0f8ff
|
|
19
|
+
"antiquewhite": 16444375, // #faebd7
|
|
20
|
+
"aquamarine": 8388564, // #7fffd4
|
|
21
|
+
"azure": 15794175, // #f0ffff
|
|
22
|
+
"beige": 16119260, // #f5f5dc
|
|
23
|
+
"bisque": 16770244, // #ffe4c4
|
|
24
|
+
"blanchedalmond": 16772045, // #ffebcd
|
|
25
|
+
"blueviolet": 9055202, // #8a2be2
|
|
26
|
+
"brown": 10824234, // #a52a2a
|
|
27
|
+
"burlywood": 14596231, // #deb887
|
|
28
|
+
"cadetblue": 6266528, // #5f9ea0
|
|
29
|
+
"chartreuse": 8388352, // #7fff00
|
|
30
|
+
"chocolate": 13789470, // #d2691e
|
|
31
|
+
"coral": 16744272, // #ff7f50
|
|
32
|
+
"cornflowerblue": 6591981, // #6495ed
|
|
33
|
+
"cornsilk": 16775388, // #fff8dc
|
|
34
|
+
"crimson": 14423100, // #dc143c
|
|
35
|
+
"cyan": 65535, // #00ffff
|
|
36
|
+
"darkblue": 139, // #00008b
|
|
37
|
+
"darkcyan": 35723, // #008b8b
|
|
38
|
+
"darkgoldenrod": 12092939, // #b8860b
|
|
39
|
+
"darkgray": 11119017, // #a9a9a9
|
|
40
|
+
"darkgreen": 25600, // #006400
|
|
41
|
+
"darkgrey": 11119017, // #a9a9a9
|
|
42
|
+
"darkkhaki": 12433259, // #bdb76b
|
|
43
|
+
"darkmagenta": 9109643, // #8b008b
|
|
44
|
+
"darkolivegreen": 5597999, // #556b2f
|
|
45
|
+
"darkorange": 16747520, // #ff8c00
|
|
46
|
+
"darkorchid": 10040012, // #9932cc
|
|
47
|
+
"darkred": 9109504, // #8b0000
|
|
48
|
+
"darksalmon": 15308410, // #e9967a
|
|
49
|
+
"darkseagreen": 9419919, // #8fbc8f
|
|
50
|
+
"darkslateblue": 4734347, // #483d8b
|
|
51
|
+
"darkslategray": 3100495, // #2f4f4f
|
|
52
|
+
"darkslategrey": 3100495, // #2f4f4f
|
|
53
|
+
"darkturquoise": 52945, // #00ced1
|
|
54
|
+
"darkviolet": 9699539, // #9400d3
|
|
55
|
+
"deeppink": 16716947, // #ff1493
|
|
56
|
+
"deepskyblue": 49151, // #00bfff
|
|
57
|
+
"dimgray": 6908265, // #696969
|
|
58
|
+
"dimgrey": 6908265, // #696969
|
|
59
|
+
"dodgerblue": 2003199, // #1e90ff
|
|
60
|
+
"firebrick": 11674146, // #b22222
|
|
61
|
+
"floralwhite": 16775920, // #fffaf0
|
|
62
|
+
"forestgreen": 2263842, // #228b22
|
|
63
|
+
"gainsboro": 14474460, // #dcdcdc
|
|
64
|
+
"ghostwhite": 16316671, // #f8f8ff
|
|
65
|
+
"gold": 16766720, // #ffd700
|
|
66
|
+
"goldenrod": 14329120, // #daa520
|
|
67
|
+
"greenyellow": 11403055, // #adff2f
|
|
68
|
+
"grey": 8421504, // #808080
|
|
69
|
+
"honeydew": 15794160, // #f0fff0
|
|
70
|
+
"hotpink": 16738740, // #ff69b4
|
|
71
|
+
"indianred": 13458524, // #cd5c5c
|
|
72
|
+
"indigo": 4915330, // #4b0082
|
|
73
|
+
"ivory": 16777200, // #fffff0
|
|
74
|
+
"khaki": 15787660, // #f0e68c
|
|
75
|
+
"lavender": 15132410, // #e6e6fa
|
|
76
|
+
"lavenderblush": 16773365, // #fff0f5
|
|
77
|
+
"lawngreen": 8190976, // #7cfc00
|
|
78
|
+
"lemonchiffon": 16775885, // #fffacd
|
|
79
|
+
"lightblue": 11393254, // #add8e6
|
|
80
|
+
"lightcoral": 15761536, // #f08080
|
|
81
|
+
"lightcyan": 14745599, // #e0ffff
|
|
82
|
+
"lightgoldenrodyellow": 16448210, // #fafad2
|
|
83
|
+
"lightgray": 13882323, // #d3d3d3
|
|
84
|
+
"lightgreen": 9498256, // #90ee90
|
|
85
|
+
"lightgrey": 13882323, // #d3d3d3
|
|
86
|
+
"lightpink": 16758465, // #ffb6c1
|
|
87
|
+
"lightsalmon": 16752762, // #ffa07a
|
|
88
|
+
"lightseagreen": 2142890, // #20b2aa
|
|
89
|
+
"lightskyblue": 8900346, // #87cefa
|
|
90
|
+
"lightslategray": 7833753, // #778899
|
|
91
|
+
"lightslategrey": 7833753, // #778899
|
|
92
|
+
"lightsteelblue": 11584734, // #b0c4de
|
|
93
|
+
"lightyellow": 16777184, // #ffffe0
|
|
94
|
+
"limegreen": 3329330, // #32cd32
|
|
95
|
+
"linen": 16445670, // #faf0e6
|
|
96
|
+
"magenta": 16711935, // #ff00ff
|
|
97
|
+
"mediumaquamarine": 6737322, // #66cdaa
|
|
98
|
+
"mediumblue": 205, // #0000cd
|
|
99
|
+
"mediumorchid": 12211667, // #ba55d3
|
|
100
|
+
"mediumpurple": 9662683, // #9370db
|
|
101
|
+
"mediumseagreen": 3978097, // #3cb371
|
|
102
|
+
"mediumslateblue": 8087790, // #7b68ee
|
|
103
|
+
"mediumspringgreen": 64154, // #00fa9a
|
|
104
|
+
"mediumturquoise": 4772300, // #48d1cc
|
|
105
|
+
"mediumvioletred": 13047173, // #c71585
|
|
106
|
+
"midnightblue": 1644912, // #191970
|
|
107
|
+
"mintcream": 16121850, // #f5fffa
|
|
108
|
+
"mistyrose": 16770273, // #ffe4e1
|
|
109
|
+
"moccasin": 16770229, // #ffe4b5
|
|
110
|
+
"navajowhite": 16768685, // #ffdead
|
|
111
|
+
"oldlace": 16643558, // #fdf5e6
|
|
112
|
+
"olivedrab": 7048739, // #6b8e23
|
|
113
|
+
"orange": 16753920, // #ffa500
|
|
114
|
+
"orangered": 16729344, // #ff4500
|
|
115
|
+
"orchid": 14315734, // #da70d6
|
|
116
|
+
"palegoldenrod": 15657130, // #eee8aa
|
|
117
|
+
"palegreen": 10025880, // #98fb98
|
|
118
|
+
"paleturquoise": 11529966, // #afeeee
|
|
119
|
+
"palevioletred": 14381203, // #db7093
|
|
120
|
+
"papayawhip": 16773077, // #ffefd5
|
|
121
|
+
"peachpuff": 16767673, // #ffdab9
|
|
122
|
+
"peru": 13468991, // #cd853f
|
|
123
|
+
"pink": 16761035, // #ffc0cb
|
|
124
|
+
"plum": 14524637, // #dda0dd
|
|
125
|
+
"powderblue": 11591910, // #b0e0e6
|
|
126
|
+
"rebeccapurple": 6697881, // #663399
|
|
127
|
+
"rosybrown": 12357519, // #bc8f8f
|
|
128
|
+
"royalblue": 4286945, // #4169e1
|
|
129
|
+
"saddlebrown": 9127187, // #8b4513
|
|
130
|
+
"salmon": 16416882, // #fa8072
|
|
131
|
+
"sandybrown": 16032864, // #f4a460
|
|
132
|
+
"seagreen": 3050327, // #2e8b57
|
|
133
|
+
"seashell": 16774638, // #fff5ee
|
|
134
|
+
"sienna": 10506797, // #a0522d
|
|
135
|
+
"skyblue": 8900331, // #87ceeb
|
|
136
|
+
"slateblue": 6970061, // #6a5acd
|
|
137
|
+
"slategray": 7372944, // #708090
|
|
138
|
+
"slategrey": 7372944, // #708090
|
|
139
|
+
"snow": 16775930, // #fffafa
|
|
140
|
+
"springgreen": 65407, // #00ff7f
|
|
141
|
+
"steelblue": 4620980, // #4682b4
|
|
142
|
+
"tan": 13808780, // #d2b48c
|
|
143
|
+
"thistle": 14204888, // #d8bfd8
|
|
144
|
+
"tomato": 16737095, // #ff6347
|
|
145
|
+
"turquoise": 4251856, // #40e0d0
|
|
146
|
+
"violet": 15631086, // #ee82ee
|
|
147
|
+
"wheat": 16113331, // #f5deb3
|
|
148
|
+
"whitesmoke": 16119285, // #f5f5f5
|
|
149
|
+
"yellowgreen": 10145074 // #9acd32
|
|
150
|
+
}
|
data/data/css.txt
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
black #000000
|
|
2
|
+
silver #c0c0c0
|
|
3
|
+
gray #808080
|
|
4
|
+
white #ffffff
|
|
5
|
+
maroon #800000
|
|
6
|
+
red #ff0000
|
|
7
|
+
purple #800080
|
|
8
|
+
fuchsia #ff00ff
|
|
9
|
+
green #008000
|
|
10
|
+
lime #00ff00
|
|
11
|
+
olive #808000
|
|
12
|
+
yellow #ffff00
|
|
13
|
+
navy #000080
|
|
14
|
+
blue #0000ff
|
|
15
|
+
teal #008080
|
|
16
|
+
aqua #00ffff
|
|
17
|
+
aliceblue #f0f8ff
|
|
18
|
+
antiquewhite #faebd7
|
|
19
|
+
aquamarine #7fffd4
|
|
20
|
+
azure #f0ffff
|
|
21
|
+
beige #f5f5dc
|
|
22
|
+
bisque #ffe4c4
|
|
23
|
+
blanchedalmond #ffebcd
|
|
24
|
+
blueviolet #8a2be2
|
|
25
|
+
brown #a52a2a
|
|
26
|
+
burlywood #deb887
|
|
27
|
+
cadetblue #5f9ea0
|
|
28
|
+
chartreuse #7fff00
|
|
29
|
+
chocolate #d2691e
|
|
30
|
+
coral #ff7f50
|
|
31
|
+
cornflowerblue #6495ed
|
|
32
|
+
cornsilk #fff8dc
|
|
33
|
+
crimson #dc143c
|
|
34
|
+
cyan #00ffff
|
|
35
|
+
darkblue #00008b
|
|
36
|
+
darkcyan #008b8b
|
|
37
|
+
darkgoldenrod #b8860b
|
|
38
|
+
darkgray #a9a9a9
|
|
39
|
+
darkgreen #006400
|
|
40
|
+
darkgrey #a9a9a9
|
|
41
|
+
darkkhaki #bdb76b
|
|
42
|
+
darkmagenta #8b008b
|
|
43
|
+
darkolivegreen #556b2f
|
|
44
|
+
darkorange #ff8c00
|
|
45
|
+
darkorchid #9932cc
|
|
46
|
+
darkred #8b0000
|
|
47
|
+
darksalmon #e9967a
|
|
48
|
+
darkseagreen #8fbc8f
|
|
49
|
+
darkslateblue #483d8b
|
|
50
|
+
darkslategray #2f4f4f
|
|
51
|
+
darkslategrey #2f4f4f
|
|
52
|
+
darkturquoise #00ced1
|
|
53
|
+
darkviolet #9400d3
|
|
54
|
+
deeppink #ff1493
|
|
55
|
+
deepskyblue #00bfff
|
|
56
|
+
dimgray #696969
|
|
57
|
+
dimgrey #696969
|
|
58
|
+
dodgerblue #1e90ff
|
|
59
|
+
firebrick #b22222
|
|
60
|
+
floralwhite #fffaf0
|
|
61
|
+
forestgreen #228b22
|
|
62
|
+
gainsboro #dcdcdc
|
|
63
|
+
ghostwhite #f8f8ff
|
|
64
|
+
gold #ffd700
|
|
65
|
+
goldenrod #daa520
|
|
66
|
+
greenyellow #adff2f
|
|
67
|
+
grey #808080
|
|
68
|
+
honeydew #f0fff0
|
|
69
|
+
hotpink #ff69b4
|
|
70
|
+
indianred #cd5c5c
|
|
71
|
+
indigo #4b0082
|
|
72
|
+
ivory #fffff0
|
|
73
|
+
khaki #f0e68c
|
|
74
|
+
lavender #e6e6fa
|
|
75
|
+
lavenderblush #fff0f5
|
|
76
|
+
lawngreen #7cfc00
|
|
77
|
+
lemonchiffon #fffacd
|
|
78
|
+
lightblue #add8e6
|
|
79
|
+
lightcoral #f08080
|
|
80
|
+
lightcyan #e0ffff
|
|
81
|
+
lightgoldenrodyellow #fafad2
|
|
82
|
+
lightgray #d3d3d3
|
|
83
|
+
lightgreen #90ee90
|
|
84
|
+
lightgrey #d3d3d3
|
|
85
|
+
lightpink #ffb6c1
|
|
86
|
+
lightsalmon #ffa07a
|
|
87
|
+
lightseagreen #20b2aa
|
|
88
|
+
lightskyblue #87cefa
|
|
89
|
+
lightslategray #778899
|
|
90
|
+
lightslategrey #778899
|
|
91
|
+
lightsteelblue #b0c4de
|
|
92
|
+
lightyellow #ffffe0
|
|
93
|
+
limegreen #32cd32
|
|
94
|
+
linen #faf0e6
|
|
95
|
+
magenta #ff00ff
|
|
96
|
+
mediumaquamarine #66cdaa
|
|
97
|
+
mediumblue #0000cd
|
|
98
|
+
mediumorchid #ba55d3
|
|
99
|
+
mediumpurple #9370db
|
|
100
|
+
mediumseagreen #3cb371
|
|
101
|
+
mediumslateblue #7b68ee
|
|
102
|
+
mediumspringgreen #00fa9a
|
|
103
|
+
mediumturquoise #48d1cc
|
|
104
|
+
mediumvioletred #c71585
|
|
105
|
+
midnightblue #191970
|
|
106
|
+
mintcream #f5fffa
|
|
107
|
+
mistyrose #ffe4e1
|
|
108
|
+
moccasin #ffe4b5
|
|
109
|
+
navajowhite #ffdead
|
|
110
|
+
oldlace #fdf5e6
|
|
111
|
+
olivedrab #6b8e23
|
|
112
|
+
orange #ffa500
|
|
113
|
+
orangered #ff4500
|
|
114
|
+
orchid #da70d6
|
|
115
|
+
palegoldenrod #eee8aa
|
|
116
|
+
palegreen #98fb98
|
|
117
|
+
paleturquoise #afeeee
|
|
118
|
+
palevioletred #db7093
|
|
119
|
+
papayawhip #ffefd5
|
|
120
|
+
peachpuff #ffdab9
|
|
121
|
+
peru #cd853f
|
|
122
|
+
pink #ffc0cb
|
|
123
|
+
plum #dda0dd
|
|
124
|
+
powderblue #b0e0e6
|
|
125
|
+
rebeccapurple #663399
|
|
126
|
+
rosybrown #bc8f8f
|
|
127
|
+
royalblue #4169e1
|
|
128
|
+
saddlebrown #8b4513
|
|
129
|
+
salmon #fa8072
|
|
130
|
+
sandybrown #f4a460
|
|
131
|
+
seagreen #2e8b57
|
|
132
|
+
seashell #fff5ee
|
|
133
|
+
sienna #a0522d
|
|
134
|
+
skyblue #87ceeb
|
|
135
|
+
slateblue #6a5acd
|
|
136
|
+
slategray #708090
|
|
137
|
+
slategrey #708090
|
|
138
|
+
snow #fffafa
|
|
139
|
+
springgreen #00ff7f
|
|
140
|
+
steelblue #4682b4
|
|
141
|
+
tan #d2b48c
|
|
142
|
+
thistle #d8bfd8
|
|
143
|
+
tomato #ff6347
|
|
144
|
+
turquoise #40e0d0
|
|
145
|
+
violet #ee82ee
|
|
146
|
+
wheat #f5deb3
|
|
147
|
+
whitesmoke #f5f5f5
|
|
148
|
+
yellowgreen #9acd32
|