unmagic-color 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 385638e771dedbaff1485e3d8d45d18e632b4210b6d6d781916ef34358c09bd6
4
- data.tar.gz: a34aa8373606265ada813caae4a495c006a9a71f3cfa8ec37c759ceb0e6f3818
3
+ metadata.gz: 276b2cc6192a6fea7e69f4893c9989434e8101c3e9c6a88b56996eeeeb910262
4
+ data.tar.gz: cd421ccce7640490b140a74a62640ee9dbbb6060f815d770b14ac12e4b1ff991
5
5
  SHA512:
6
- metadata.gz: 1f484d35f71337bf9055569537a97337ea4cba6ddadf74774e73d93d6f1567a5b2934312e76635755fb6ca52aae1317ca9e47055d376e836f89d0ec8298af4d3
7
- data.tar.gz: c99cd2ec04a304a7ef707449c21503238e6db4dee39ab31b6b73e731ab2e26e8a7d0bbf12b9a46d214f58cc354d00707bf40fd69ce0abab6e380f99205219de1
6
+ metadata.gz: 2da573372028a3d08793d01bcd9245a24fc88934085b081712934e4606a2d60ff03d8c8f6f94b06abb2fb6817e1b5b0acdf8ac2fd332e1d9f9b2923a90221d5c
7
+ data.tar.gz: 8a17575b7f89b7f9c29d613208972242bd851e42b25659a7533a4c6ed156ce14f9f9396148aa6e171ad5a8e0159395d8e9f9e28b881fa000bbdeb6492cc40388
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.1] - 2026-01-05
11
+
12
+ ### Added
13
+ - `to_hex` method for HSL colors (converts via RGB)
14
+ - `to_hex` method for OKLCH colors (converts via RGB)
15
+
10
16
  ## [0.2.0] - 2026-01-05
11
17
 
12
18
  ### Added
@@ -75,5 +81,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
75
81
  - HSL color progressions for palette generation
76
82
  - Multiple hash functions for string-to-color derivation
77
83
 
84
+ [0.2.1]: https://github.com/unreasonable-magic/unmagic-color/releases/tag/v0.2.1
78
85
  [0.2.0]: https://github.com/unreasonable-magic/unmagic-color/releases/tag/v0.2.0
79
86
  [0.1.0]: https://github.com/unreasonable-magic/unmagic-color/releases/tag/v0.1.0
data/README.md CHANGED
@@ -159,31 +159,22 @@ Generate color palettes based on color theory relationships:
159
159
  color = Unmagic::Color.parse("#FF5733")
160
160
 
161
161
  # Complementary - opposite on the color wheel (180°)
162
- complement = color.complementary
163
- # => Single color opposite on the wheel
162
+ color.complementary.to_hex # => "#33daff"
164
163
 
165
164
  # Analogous - adjacent colors (default ±30°)
166
- analogous = color.analogous
167
- # => [color at -30°, color at +30°]
168
- analogous = color.analogous(angle: 15) # Custom angle
165
+ color.analogous.map(&:to_hex) # => ["#ff3374", "#ffbe33"]
169
166
 
170
167
  # Triadic - three colors equally spaced (120° apart)
171
- triadic = color.triadic
172
- # => [color at +120°, color at +240°]
168
+ color.triadic.map(&:to_hex) # => ["#33ff58", "#5833ff"]
173
169
 
174
170
  # 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
171
+ color.split_complementary.map(&:to_hex) # => ["#33ffbe", "#3374ff"]
178
172
 
179
173
  # Tetradic Square - four colors equally spaced (90° apart)
180
- tetradic = color.tetradic_square
181
- # => [color at +90°, color at +180°, color at +270°]
174
+ color.tetradic_square.map(&:to_hex) # => ["#74ff33", "#33daff", "#be33ff"]
182
175
 
183
176
  # 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
177
+ color.tetradic_rectangle.map(&:to_hex) # => ["#daff33", "#33daff", "#5833ff"]
187
178
  ```
188
179
 
189
180
  ### Color Variations
@@ -196,8 +187,7 @@ Generate shades, tints, tones, and monochromatic palettes:
196
187
  color = Unmagic::Color.parse("#3366CC")
197
188
 
198
189
  # Monochromatic - same hue with varying lightness
199
- mono = color.monochromatic(steps: 5)
200
- # => Array of 5 colors from dark to light
190
+ color.monochromatic(steps: 5).map(&:to_hex) # => ["#0f1f3d", "#214285", "#3366cc", "#7a9cde", "#c2d1f0"]
201
191
 
202
192
  # Shades - progressively darker (mixed with black)
203
193
  shades = color.shades(steps: 5)
@@ -216,11 +206,11 @@ All harmony and variation methods preserve the original color space:
216
206
 
217
207
  ```ruby
218
208
  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
209
+ hsl.complementary.to_hex # => "#e65e19"
210
+ hsl.shades(steps: 3).map(&:to_hex) # => ["#1587bf", "#116c99", "#0d5173"]
221
211
 
222
212
  rgb = Unmagic::Color.parse("#FF5733")
223
- rgb.analogous # => Array of RGB colors
213
+ rgb.analogous.map(&:to_hex) # => ["#ff3374", "#ffbe33"]
224
214
  ```
225
215
 
226
216
  ### HSL-Specific Features
@@ -234,11 +224,8 @@ muted = hsl.desaturate(0.3)
234
224
  shifted = hsl.adjust_hue(30)
235
225
 
236
226
  # Create color progressions
237
- palette = hsl.progression(
238
- steps: 5,
239
- lightness: [30, 50, 70, 85, 95]
240
- )
241
- # => Array of 5 HSL colors with varying lightness
227
+ hsl.progression(steps: 5, lightness: [30, 50, 70, 85, 95]).map(&:to_hex)
228
+ # => ["#175e82", "#269dd9", "#7dc4e8", "#bee2f4", "#e9f5fb"]
242
229
  ```
243
230
 
244
231
  ### Generating Colors from Strings
@@ -14,7 +14,7 @@ module Unmagic
14
14
  #
15
15
  # @return [String] The formatted help text
16
16
  def render
17
- link = highlighter.link("https://github.com/unmagic/unmagic-color")
17
+ link = highlighter.link("https://github.com/unreasonable-magic/unmagic-color")
18
18
 
19
19
  code = highlighter.highlight(<<~RUBY)
20
20
  # Parse colors
@@ -291,6 +291,15 @@ module Unmagic
291
291
  to_rgb.to_oklch
292
292
  end
293
293
 
294
+ # Convert to hex string.
295
+ #
296
+ # Converts via RGB as an intermediate step.
297
+ #
298
+ # @return [String] The color as a hex string (e.g., "#ff5733")
299
+ def to_hex
300
+ to_rgb.to_hex
301
+ end
302
+
294
303
  # Calculate the relative luminance.
295
304
  #
296
305
  # Converts to RGB first, then calculates luminance.
@@ -302,6 +302,15 @@ module Unmagic
302
302
  Unmagic::Color::RGB.new(red: r, green: g, blue: b, alpha: @alpha)
303
303
  end
304
304
 
305
+ # Convert to hex string.
306
+ #
307
+ # Converts via RGB as an intermediate step.
308
+ #
309
+ # @return [String] The color as a hex string (e.g., "#ff5733")
310
+ def to_hex
311
+ to_rgb.to_hex
312
+ end
313
+
305
314
  # Calculate the relative luminance.
306
315
  #
307
316
  # In OKLCH, the lightness value directly represents perceptual luminance,
@@ -3,6 +3,6 @@
3
3
  module Unmagic
4
4
  class Color
5
5
  # Current version of the Unmagic::Color gem
6
- VERSION = "0.2.0"
6
+ VERSION = "0.2.1"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unmagic-color
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Pitt