color 1.7.1 → 2.0.0.pre.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.
Files changed (53) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +298 -0
  3. data/CODE_OF_CONDUCT.md +128 -0
  4. data/CONTRIBUTING.md +70 -0
  5. data/CONTRIBUTORS.md +10 -0
  6. data/LICENCE.md +27 -0
  7. data/Manifest.txt +11 -21
  8. data/README.md +54 -0
  9. data/Rakefile +74 -53
  10. data/SECURITY.md +34 -0
  11. data/lib/color/cielab.rb +348 -0
  12. data/lib/color/cmyk.rb +279 -213
  13. data/lib/color/grayscale.rb +128 -160
  14. data/lib/color/hsl.rb +205 -173
  15. data/lib/color/rgb/colors.rb +177 -163
  16. data/lib/color/rgb.rb +534 -537
  17. data/lib/color/version.rb +5 -0
  18. data/lib/color/xyz.rb +214 -0
  19. data/lib/color/yiq.rb +91 -46
  20. data/lib/color.rb +208 -141
  21. data/test/fixtures/cielab.json +444 -0
  22. data/test/minitest_helper.rb +20 -4
  23. data/test/test_cmyk.rb +49 -71
  24. data/test/test_color.rb +58 -106
  25. data/test/test_grayscale.rb +35 -56
  26. data/test/test_hsl.rb +72 -76
  27. data/test/test_rgb.rb +195 -267
  28. data/test/test_yiq.rb +12 -30
  29. metadata +165 -150
  30. checksums.yaml.gz.sig +0 -0
  31. data/.autotest +0 -5
  32. data/.gemtest +0 -0
  33. data/.hoerc +0 -2
  34. data/.minitest.rb +0 -2
  35. data/.travis.yml +0 -35
  36. data/Contributing.rdoc +0 -60
  37. data/Gemfile +0 -9
  38. data/History.rdoc +0 -172
  39. data/Licence.rdoc +0 -27
  40. data/README.rdoc +0 -50
  41. data/lib/color/css.rb +0 -7
  42. data/lib/color/palette/adobecolor.rb +0 -260
  43. data/lib/color/palette/gimp.rb +0 -104
  44. data/lib/color/palette/monocontrast.rb +0 -164
  45. data/lib/color/palette.rb +0 -4
  46. data/lib/color/rgb/contrast.rb +0 -57
  47. data/lib/color/rgb/metallic.rb +0 -28
  48. data/test/test_adobecolor.rb +0 -405
  49. data/test/test_css.rb +0 -19
  50. data/test/test_gimp.rb +0 -87
  51. data/test/test_monocontrast.rb +0 -130
  52. data.tar.gz.sig +0 -0
  53. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YWMzMTI3YmE1NGRlNzZmYTY1ZWQ3ZWE2MTk2MTM2ZTFlOTAyYWMzYw==
5
- data.tar.gz: !binary |-
6
- YTE5YzdlZmQ1ZjA0MjljMDIzZDU0NDdlOWQyOTQyYjNhY2ZkZGJkOA==
2
+ SHA256:
3
+ metadata.gz: 4e5858bb16512729edfebe8016f4f773cba22557703a83532c0bdf741d1bae34
4
+ data.tar.gz: ad8833b876bbf9e3b8741044a7d2714c324f4938764745584fe23b3cb0b70be8
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MzhkMTVmMmNlMWM3ZTBlNmRiNDY1ZmViY2YyOGMzMjI3NjFmODc4ZDhiZjgy
10
- NTM1NDhhNWViOTM2ZjE3NDYxZmI4NDFjNDdmMWI5MWFlNWU5YTEyNDZiOGJk
11
- ZjBhZjJlM2MyNGU4ZTU1M2FlYWVhOTJiZGQzNGY4YzJiNDUxMzU=
12
- data.tar.gz: !binary |-
13
- NzRkOWE3MjQwZDMxZmUxMjNmYjNjMjVhNmQ0MjQzNjEzNmJiZjYxNWZiZjgy
14
- MjE5MDQ5Y2ZjNmYzYzUzMjQ1NDk0Nzg0Yzk3NDcxOWQ1NmMyZGExMGE3Y2Nk
15
- MDBhMGUxZWQ3ZTZhYjk0MWQ3OGQ4OThiNjZjY2IwMjY5NTA3NzA=
6
+ metadata.gz: 96ad5fe214c3d719626d2ba4a205053f2feccd1d93a405f9f1c9fc3b17afe84a43fb0f1cf2eed24440f1788348bd560f44dbb0510d8994e5c596fd5290a11346
7
+ data.tar.gz: ce74123cb7c51a3e875bdc8f210df2c6e7b1f5bb64e63f1b9d6de9debd6a2ddab5c3b9d8ceeda19eaee6a90be3b5dbc571df9c6fd1b3d7b8b0d15addf20fc25c
data/CHANGELOG.md ADDED
@@ -0,0 +1,298 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0.pre.0 / 2025-06-15
4
+
5
+ Color 2.0.0 is a major release of the Color library.
6
+
7
+ ### 💣 Breaking Changes
8
+
9
+ Color 2.0 contains breaking changes. Functionality previously deprecated has
10
+ been removed, but other functionality has been changed or removed as part of
11
+ this release without warning.
12
+
13
+ - The minimum supported version of Ruby is 3.2.
14
+
15
+ - Color classes are now immutable implementations of Data objects (first
16
+ introduced in Ruby 3.2). This will restrict Color 2 from running on versions
17
+ of JRuby before JRuby 10.
18
+
19
+ - The constants `Color::COLOR_VERSION` and `Color::COLOR_TOOLS_VERSION` have
20
+ been removed; there is only `Color::VERSION`. This reverses a planned
21
+ deprecation decision made more than ten years ago that no longer makes sense.
22
+
23
+ - All named color classes at `Color` have been removed as planned.
24
+
25
+ - `Color::RGB::BeccaPurple` has been removed as an alias for
26
+ `Color::RGB::RebeccaPurple`.
27
+
28
+ - The pseudo-constructor `Color.new` has been removed.
29
+
30
+ - Color class constructors no longer yield the constructed color if a block is
31
+ passed.
32
+
33
+ - Renamed `Color::COLOR_EPSILON` and `Color::COLOR_TOLERANCE` to
34
+ `Color::EPSILON` and `Color::TOLERANCE`. These aren't private constants
35
+ because they need to be accessed throughout Color, but they are _internal_
36
+ constants that should not be used outside of the Color library or functions
37
+ exposed therein.
38
+
39
+ - PDF format functions `#pdf_fill` and `#pdf_stroke` have been removed from
40
+ `Color::CMYK`, `Color::Grayscale`, and `Color::RGB`. The supporting internal
41
+ constants `Color::<class>::PDF_FORMAT_STR` have also been removed.
42
+
43
+ - Palette processing classes, `Color::Palette::AdobeColor`,
44
+ `Color::Palette::Gimp`, and `Color::Palette::MonoContrast` have been removed.
45
+ Persons interested in using these are encouraged to extract them from
46
+ [Color 1.8][color-1.8] and adapt them to use Color 2.0 APIs.
47
+
48
+ - CSS methods (`#css_rgb`, `#css_rgba`, `#css_hsl`, `#css_hsla`) have been
49
+ replaced with `#css` on color classes that have CSS representations. The
50
+ output of `#css` differs (Color 1.8 used the legacy CSS color formats; Color
51
+ 2.0 uses modern CSS color formats).
52
+
53
+ - `Color::GrayScale` has been renamed to `Color::Grayscale`. The alias constant
54
+ `Color::GreyScale` has been removed.
55
+
56
+ - The `#html` method has been removed from all color classes except Color::RGB.
57
+
58
+ - Named RGB colors are no longer defined automatically, but must be loaded
59
+ explicitly by requiring `color/rgb/colors`. This resolves [#30][issue-30].
60
+
61
+ - `Color:CSS#[]` has been removed, as has the containing namespace. It has
62
+ always been a shallow wrapper around `Color::RGB.by_name`.
63
+
64
+ ### 🚀 New Features
65
+
66
+ - `Color::CIELAB` and `Color::XYZ` namespaces have been added. Separate
67
+ implementations were submitted by David Heitzman and @stiff (in [#8][pr-8] and
68
+ [#11][pr-11]), but I have reworked the code substantially. These
69
+ implementations were originally as `Color::LAB` and include a new contrast
70
+ calculation using the ΔE\*00 algorithm.
71
+
72
+ ### Internal
73
+
74
+ - Updated project structure for how I manage Ruby libraries in 2025. This
75
+ includes increased release security (MFA is required for all releases,
76
+ automated releases are enabled), full GitHub Actions, Dependabot, Standard
77
+ Ruby, and more.
78
+
79
+ ## 1.8 / 2015-10-26
80
+
81
+ - Add an optional `alpha` parameter to all `#css` calls. Thanks to Luke
82
+ Bennellick (@bennell) and Alexander Popov (@AlexWayfer) for independently
83
+ implemented submissions. Merged from [#15][pull-15].
84
+
85
+ - Improve constant detection to prevent incorrectly identified name collisions
86
+ with various other libraries such as Azure deployment tools. Based on work by
87
+ Matthew Draper (@matthewd) in [#24][pull-24].
88
+
89
+ - Prevent `Color.equivalent?` comparisons from using non-Color types for
90
+ comparison. Fix provided by Benjamin Guest (@bguest) in [#18][pull-18].
91
+
92
+ - This project now has a [Code of Conduct](CODE_OF_CONDUCT.md).
93
+
94
+ ## 1.7.1 / 2014-06-12
95
+
96
+ - Renamed `Color::RGB::BeccaPurple` to `Color::RGB::RebeccaPurple` as stipulated
97
+ by Eric Meyer. For purposes of backwards compatibility, the previous name is
98
+ still permitted, but its use is strongly discouraged, and it will be removed
99
+ in the Color 2.0 release.
100
+ <http://meyerweb.com/eric/thoughts/2014/06/19/rebeccapurple/>
101
+
102
+ ## 1.7 / 2014-06-12
103
+
104
+ - Added `Color::RGB::BeccaPurple` (#663399) in honour of Rebecca Meyer, the
105
+ daughter of Eric Meyer, who passed away on the 7 June 2014. Her favourite
106
+ color was purple. `#663399becca`
107
+ <https://twitter.com/meyerweb/status/476089708674428929>
108
+ <http://www.zeldman.com/2014/06/10/the-color-purple/>
109
+ <http://discourse.specifiction.org/t/name-663399-becca-purple-in-css4-color/225>
110
+
111
+ - Changed the homepage in the gem to point to GitHub instead of RubyForge, which
112
+ has been shut down. Fixes [#10][issue-10], reported by @voxik.
113
+
114
+ ## 1.6 / 2014-05-19
115
+
116
+ - Aaron Hill (@armahillo) implemented the CIE Delta E 94 method by which an RGB
117
+ color can be asked for the closest matching color from a list of provided
118
+ colors. Fixes [#5][issue-5].
119
+
120
+ - To implement `#closest_match` and `#delta_e94`, conversion methods for sRGB to
121
+ XYZ and XYZ to L\*a\*b\* space were implemented. These should be considered
122
+ experimental.
123
+
124
+ - Ensured that the gem manifest was up-to-date. Fixes [#4][issue-4] reported by
125
+ @boutil. Thanks!
126
+
127
+ - Fixed problems with Travis builds. Note that Ruby 1.9.2 is no longer tested.
128
+ Rubinius remains in a 'failure-tolerated' mode.
129
+
130
+ - Color 1.6 is, barring security patches, the last release of Color that will
131
+ support Ruby 1.8.
132
+
133
+ ## 1.5.1 / 2014-01-28
134
+
135
+ - color 1.5 was a yanked release.
136
+
137
+ - Added new methods to `Color::RGB` to make it so that the default defined
138
+ colors can be looked up by hex, name, or both.
139
+
140
+ - Added a method to `Color::RGB` to extract colors from text by hex, name, or
141
+ both.
142
+
143
+ - Added new common methods for color names. Converted colors do not retain
144
+ names.
145
+
146
+ - Restructured color comparisons to use protocols instead of custom
147
+ implementations. This makes it easier to implement new color classes. To make
148
+ this work, color classes should `include` Color only need to implement
149
+ `#coerce(other)`, `#to_a`, and supported conversion methods (e.g., `#to_rgb`).
150
+
151
+ - Added @daveheitzman's initial implementation of a RGB contrast method as an
152
+ extension file: `require 'color/rgb/contrast'`. This method and the value it
153
+ returns should be considered experimental; it requires further examination to
154
+ ensure that the results produced are consistent with the contrast comparisons
155
+ used in `Color::Palette::MonoContrast`.
156
+
157
+ - Reducing duplicated code.
158
+
159
+ - Moved `lib/color/rgb-colors.rb` to `lib/color/rgb/colors.rb`.
160
+
161
+ - Improved the way that named colors are specified internally.
162
+
163
+ - Fixed bugs with Ruby 1.8.7 that may have been introduced in color 1.4.2.
164
+
165
+ - Added simplecov for test coverage analysis.
166
+
167
+ - Modernized Travis CI support.
168
+
169
+ ## 1.4.2 / 2013-06-30
170
+
171
+ - Modernized Hoe installation of Color, removing some dependencies.
172
+
173
+ - Switched to Minitest.
174
+
175
+ - Turned on Travis CI.
176
+
177
+ - Started using Code Climate.
178
+
179
+ - Small code formatting cleanup that touched pretty much every file.
180
+
181
+ ## 1.4.1 / 2010-02-03
182
+
183
+ - Imported to GitHub.
184
+
185
+ - Converted to Hoe 2.5 spec format.
186
+
187
+ ## 1.4.0 / 2007-02-11
188
+
189
+ - Merged Austin Ziegler's color-tools library (previously part of the Ruby PDF
190
+ Tools project) with Matt Lyon's color library.
191
+
192
+ - The HSL implementation from the Color class has been merged into
193
+ `Color::HSL`. Color is a module the way it was for color-tools.
194
+
195
+ - A thin veneer has been written to allow Color::new to return a `Color::HSL`
196
+ instance; `Color::HSL` supports as many methods as possible that were
197
+ previously supported by the Color class.
198
+
199
+ - Values that were previously rounded by Color are no longer rounded;
200
+ fractional values matter.
201
+
202
+ - Converted to hoe for project management.
203
+
204
+ - Moved to the next step of deprecating `Color::<name>` values; printing a
205
+ warning for each use (see the history for color-tools 1.3.0).
206
+
207
+ - Print a warning on the access of either `VERSION` or `COLOR_TOOLS_VERSION`;
208
+ the version constant is now `COLOR_VERSION`.
209
+
210
+ - Added humanized versions of accessors (e.g., CMYK colors now have both #cyan
211
+ and #c to access the cyan component of the color; #cyan provides the value as
212
+ a percentage).
213
+
214
+ - Added CSS3 formatters for RGB, RGBA, HSL, and HSLA outputs. Note that the
215
+ Color library does not yet have a way of setting alpha opacity, so the output
216
+ for RGBA and HSLA are at full alpha opacity (1.0). The values are output with
217
+ two decimal places.
218
+
219
+ - Applied a patch to provide simple arithmetic color addition and subtraction to
220
+ `Color::GrayScale` and `Color::RGB`. The patch was contributed by Jeremy
221
+ Hinegardner. This patch also provides the ability to return the maximum RGB
222
+ value as a grayscale color.
223
+
224
+ - Fixed two problems reported by Jean Krohn against color-tools relating to
225
+ RGB-to-HSL and HSL-to-RGB conversion. (Color and color-tools use the same
226
+ formulas, but the ordering of the calculations is slightly different with
227
+ Color and did not suffer from this problem; color-tools was more sensitive to
228
+ floating-point values and precision errors.)
229
+
230
+ - Fixed an issue with HSL/RGB conversions reported by Adam Johnson.
231
+
232
+ - Added an Adobe Color swatch (Photoshop) palette reader,
233
+ `Color::Palette::AdobeColor` (for `.aco` files only).
234
+
235
+ ## Color 0.1.0 / 2006-08-05
236
+
237
+ - Added HSL (degree, percent, percent) interface.
238
+
239
+ - Removed RGB instance variable; color is managed internally as HSL floating
240
+ point.
241
+
242
+ - Tests!
243
+
244
+ ## color-tools 1.3.0
245
+
246
+ - Added new metallic colors suggested by Jim Freeze. These are in the namespace
247
+ `Color::Metallic`.
248
+
249
+ - Colours that were defined in the Color namespace (e.g., `Color::Red`,
250
+ `Color::AliceBlue`) are now defined in Color::RGB (e.g., `Color::RGB::Red`,
251
+ `Color::RGB::AliceBlue`). They are added back to the Color namespace on the
252
+ first use of the old colors and a warning is printed. In version 1.4, this
253
+ warning will be printed on every use of the old colors. In version 1.5, the
254
+ backwards compatible support for colors like Color::Red will be removed
255
+ completely.
256
+
257
+ - Added the `Color::CSS` module that provides a name lookup of
258
+ `Color::RGB`-namespace constants with `Color::CSS[name]`. Most of these colors
259
+ (which are mirrored from the `Color::RGB` default colors) are only
260
+ "officially" recognised under the CSS3 color module or SVG.
261
+
262
+ - Added the `Color::HSL` color space and some helper utilities to `Color::RGB`
263
+ for color manipulation using the HSL value.
264
+
265
+ - Controlled internal value replacement to be between 0 and 1 for all colors.
266
+
267
+ - Updated `Color::Palette::Gimp` to more meaningfully deal with duplicate named
268
+ colors. Named colors now return an array of colors.
269
+
270
+ - Indicated the plans for some methods and constants out to color-tools 2.0.
271
+
272
+ - Added unit tests and fixed a number of hidden bugs because of them.
273
+
274
+ ## color-tools 1.2.0
275
+
276
+ - Changed installer from a custom-written install.rb to setup.rb 3.3.1-modified.
277
+
278
+ - Added `Color::GreyScale` (or `Color::GrayScale`).
279
+
280
+ - Added `Color::YIQ`. This color definition is incomplete; it does not have
281
+ conversions from YIQ to other color spaces.
282
+
283
+ ## color-tools 1.1.0
284
+
285
+ - Added `color/palette/gimp` to support the reading and use of GIMP color
286
+ palettes.
287
+
288
+ ## color-tools 1.0.0
289
+
290
+ - Initial release.
291
+
292
+ [color-1.8]: https://github.com/halostatue/color/tree/v1.8
293
+ [css-color]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color
294
+ [css-device-cmyk]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/device-cmyk
295
+ [issue-10]: https://github.com/halostatue/color/issues/10
296
+ [issue-30]: https://github.com/halostatue/color/issues/30
297
+ [pr-11]: https://github.com/halostatue/color/pull/11
298
+ [pr-8]: https://github.com/halostatue/color/pulls/8
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at [INSERT CONTACT
63
+ METHOD]. All complaints will be reviewed and investigated promptly and fairly.
64
+
65
+ All community leaders are obligated to respect the privacy and security of the
66
+ reporter of any incident.
67
+
68
+ ## Enforcement Guidelines
69
+
70
+ Community leaders will follow these Community Impact Guidelines in determining
71
+ the consequences for any action they deem in violation of this Code of Conduct:
72
+
73
+ ### 1. Correction
74
+
75
+ **Community Impact**: Use of inappropriate language or other behavior deemed
76
+ unprofessional or unwelcome in the community.
77
+
78
+ **Consequence**: A private, written warning from community leaders, providing
79
+ clarity around the nature of the violation and an explanation of why the
80
+ behavior was inappropriate. A public apology may be requested.
81
+
82
+ ### 2. Warning
83
+
84
+ **Community Impact**: A violation through a single incident or series of
85
+ actions.
86
+
87
+ **Consequence**: A warning with consequences for continued behavior. No
88
+ interaction with the people involved, including unsolicited interaction with
89
+ those enforcing the Code of Conduct, for a specified period of time. This
90
+ includes avoiding interactions in community spaces as well as external channels
91
+ like social media. Violating these terms may lead to a temporary or permanent
92
+ ban.
93
+
94
+ ### 3. Temporary Ban
95
+
96
+ **Community Impact**: A serious violation of community standards, including
97
+ sustained inappropriate behavior.
98
+
99
+ **Consequence**: A temporary ban from any sort of interaction or public
100
+ communication with the community for a specified period of time. No public or
101
+ private interaction with the people involved, including unsolicited interaction
102
+ with those enforcing the Code of Conduct, is allowed during this period.
103
+ Violating these terms may lead to a permanent ban.
104
+
105
+ ### 4. Permanent Ban
106
+
107
+ **Community Impact**: Demonstrating a pattern of violation of community
108
+ standards, including sustained inappropriate behavior, harassment of an
109
+ individual, or aggression toward or disparagement of classes of individuals.
110
+
111
+ **Consequence**: A permanent ban from any sort of public interaction within the
112
+ community.
113
+
114
+ ## Attribution
115
+
116
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117
+ version 2.1, available at
118
+ <https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.
119
+
120
+ Community Impact Guidelines were inspired by
121
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
122
+
123
+ For answers to common questions about this code of conduct, see the FAQ at
124
+ <https://www.contributor-covenant.org/faq>. Translations are available at
125
+ <https://www.contributor-covenant.org/translations>.
126
+
127
+ [homepage]: https://www.contributor-covenant.org
128
+ [Mozilla CoC]: https://github.com/mozilla/diversity
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,70 @@
1
+ # Contributing
2
+
3
+ Contribution to color is encouraged in any form: a bug report, a feature
4
+ request, or code contributions. There are a few DOs and DON'Ts for
5
+
6
+ - DO:
7
+
8
+ - Keep the coding style that already exists for any updated Ruby code (support
9
+ or otherwise). I use [Standard Ruby][standardrb] for linting and formatting.
10
+
11
+ - Use thoughtfully-named topic branches for contributions. Rebase your commits
12
+ into logical chunks as necessary.
13
+
14
+ - Use [quality commit messages][qcm].
15
+
16
+ - Add your name or GitHub handle to `CONTRIBUTORS.md` and a record in the
17
+ `CHANGELOG.md` as a separate commit from your main change. (Follow the style
18
+ in the `CHANGELOG.md` and provide a link to your PR.)
19
+
20
+ - Add or update tests as appropriate for your change. The test suite is
21
+ written with [minitest][minitest].
22
+
23
+ - Add or update documentation as appropriate for your change. The
24
+ documentation is RDoc; color does not use extensions that may be present in
25
+ alternative documentation generators.
26
+
27
+ - DO NOT:
28
+
29
+ - Modify `VERSION` in `lib/color/version.rb`. When your patch is accepted and
30
+ a release is made, the version will be updated at that point.
31
+
32
+ - Modify `color.gemspec`; it is a generated file. (You _may_ use
33
+ `rake gemspec` to regenerate it if your change involves metadata related to
34
+ gem itself).
35
+
36
+ - Modify the `Gemfile`.
37
+
38
+ ## Test Dependencies
39
+
40
+ color uses Ryan Davis's [Hoe][Hoe] to manage the release process, and it adds a
41
+ number of rake tasks. You will mostly be interested in `rake`, which runs the
42
+ tests the same way that `rake test` will do.
43
+
44
+ To assist with the installation of the development dependencies for mime-types,
45
+ I have provided the simplest possible Gemfile pointing to the (generated)
46
+ `color.gemspec` file. This will permit you to do `bundle install` to get the
47
+ development dependencies.
48
+
49
+ You can run tests with code coverage analysis by running `rake coverage`.
50
+
51
+ ## Workflow
52
+
53
+ Here's the most direct way to get your work merged into the project:
54
+
55
+ - Fork the project.
56
+ - Clone down your fork (`git clone git://github.com/<username>/color.git`).
57
+ - Create a topic branch to contain your change
58
+ (`git checkout -b my_awesome_feature`).
59
+ - Hack away, add tests. Not necessarily in that order.
60
+ - Make sure everything still passes by running `rake`.
61
+ - If necessary, rebase your commits into logical chunks, without errors.
62
+ - Push the branch up (`git push origin my_awesome_feature`).
63
+ - Create a pull request against halostatue/color and describe what your change
64
+ does and the why you think it should be merged.
65
+
66
+ [hoe]: https://github.com/seattlerb/hoe
67
+ [minitest]: https://github.com/seattlerb/minitest
68
+ [mtd]: https://github.com/mime-types/mime-types-data
69
+ [qcm]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
70
+ [standardrb]: https://github.com/standardrb/standard
data/CONTRIBUTORS.md ADDED
@@ -0,0 +1,10 @@
1
+ # Contributors
2
+
3
+ - Austin Ziegler created color-tools.
4
+ - Matt Lyons created color.
5
+ - Dave Heitzman (contrast comparison, CIELAB color support)
6
+ - Thomas Sawyer
7
+ - Aaron Hill (CIE94 color matching)
8
+ - Luke Bennellick
9
+ - @stiff (CIELAB color support)
10
+ - Matthew Draper
data/LICENCE.md ADDED
@@ -0,0 +1,27 @@
1
+ # Licence
2
+
3
+ - Copyright 2005-2025 Austin Ziegler, Matt Lyon, and other contributors.
4
+
5
+ The software in this repository is made available under the MIT license.
6
+
7
+ ## MIT License
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
10
+ this software and associated documentation files (the "Software"), to deal in
11
+ the Software without restriction, including without limitation the rights to
12
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
13
+ the Software, and to permit persons to whom the Software is furnished to do so,
14
+ subject to the following conditions:
15
+
16
+ - The names of its contributors may not be used to endorse or promote products
17
+ derived from this software without specific prior written permission.
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt CHANGED
@@ -1,37 +1,27 @@
1
- .autotest
2
- .gemtest
3
- .hoerc
4
- .minitest.rb
5
- .travis.yml
6
- Contributing.rdoc
7
- Gemfile
8
- History.rdoc
9
- Licence.rdoc
1
+ CHANGELOG.md
2
+ CODE_OF_CONDUCT.md
3
+ CONTRIBUTING.md
4
+ CONTRIBUTORS.md
5
+ LICENCE.md
10
6
  Manifest.txt
11
- README.rdoc
7
+ README.md
12
8
  Rakefile
9
+ SECURITY.md
13
10
  lib/color.rb
11
+ lib/color/cielab.rb
14
12
  lib/color/cmyk.rb
15
- lib/color/css.rb
16
13
  lib/color/grayscale.rb
17
14
  lib/color/hsl.rb
18
- lib/color/palette.rb
19
- lib/color/palette/adobecolor.rb
20
- lib/color/palette/gimp.rb
21
- lib/color/palette/monocontrast.rb
22
15
  lib/color/rgb.rb
23
16
  lib/color/rgb/colors.rb
24
- lib/color/rgb/contrast.rb
25
- lib/color/rgb/metallic.rb
17
+ lib/color/version.rb
18
+ lib/color/xyz.rb
26
19
  lib/color/yiq.rb
20
+ test/fixtures/cielab.json
27
21
  test/minitest_helper.rb
28
- test/test_adobecolor.rb
29
22
  test/test_cmyk.rb
30
23
  test/test_color.rb
31
- test/test_css.rb
32
- test/test_gimp.rb
33
24
  test/test_grayscale.rb
34
25
  test/test_hsl.rb
35
- test/test_monocontrast.rb
36
26
  test/test_rgb.rb
37
27
  test/test_yiq.rb
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Color -- Color Math in Ruby
2
+
3
+ - code :: <https://github.com/halostatue/color>
4
+ - issues :: <https://github.com/halostatue/color/issues>
5
+ - changelog :: <https://github.com/halostatue/color/blob/main/CHANGELOG.md>
6
+ - continuous integration ::
7
+ [![Build Status](https://github.com/halostatue/color/actions/workflows/ci.yml/badge.svg)][ci-workflow]
8
+ - test coverage ::
9
+ [![Coverage](https://coveralls.io/repos/halostatue/color/badge.svg?branch=main&service=github)][coveralls]
10
+
11
+ ## Description
12
+
13
+ Color is a Ruby library to provide RGB, CMYK, HSL, and other color space
14
+ manipulation support to applications that require it. It provides optional named
15
+ RGB colors that are commonly supported in HTML, # SVG, and X11 applications.
16
+
17
+ The Color library performs purely mathematical manipulation of the colors based
18
+ on color theory without reference to device color profiles (such as sRGB or
19
+ Adobe RGB). For most purposes, when working with RGB and HSL color spaces, this
20
+ won't matter. Absolute color spaces (like CIE LAB and CIE XYZ) cannot be
21
+ reliably converted to relative color spaces (like RGB) without color profiles.
22
+ When necessary for conversions, Color provides D65 and D50 reference white
23
+ values in Color::XYZ.
24
+
25
+ Color 2.0 is a major release, dropping support for all versions of Ruby prior to
26
+ 3.2 as well as removing or renaming a number of features. The main breaking
27
+ changes are:
28
+
29
+ - Color classes are immutable Data objects; they are no longer mutable.
30
+ - RGB named colors are no longer loaded on gem startup, but must be required
31
+ explicitly (this is _not_ done via `autoload` because there are more than 100
32
+ named colors with spelling variations) with `require "color/rgb/colors"`.
33
+ - Color palettes have been removed.
34
+ - `Color::CSS` and `Color::CSS#[]` have been removed.
35
+
36
+ ## Examples
37
+
38
+ Suppose you want to make a given RGB color a little lighter. Adjusting the RGB
39
+ color curves will change the hue and saturation will also change. Instead, use
40
+ the CIE LAB color space keeping the `color` components intact, altering only the
41
+ lightness component:
42
+
43
+ ```ruby
44
+ c = Color::RGB.from_values(r, g, b).to_lab
45
+
46
+ if (t = c.l / 50.0) < 1
47
+ c.l = 50 * ((1.0 - t) * Math.sqrt(t) + t**2)
48
+ end
49
+
50
+ c.to_rgb
51
+ ```
52
+
53
+ [ci-workflow]: https://github.com/halostatue/color/actions/workflows/ci.yml
54
+ [coveralls]: https://coveralls.io/github/halostatue/color?branch=main