Added an .opacity
method to set the opacity of a color. (credit @matildasmeds)
'red'.paint.opacity(0.3).to_rgb #=> 'rgba(255, 0, 0, 0.3)'
You can generate custom palettes on the fly without predefining them now. The
old way of defining them with a name via Chroma.define_palette
still works
too.
# New dynamic way
'red'.paint.custom_palette do
spin 60
spin 180
end
#=> [red, yellow, cyan]
Method Changes:
- Renamed options for analogous palette method.
:results
->:size
:slices
->:slice_by
- Renamed option for monochromatic palette method.
:results
->:size
Miscellaneous Changes:
- Add remaining specs for public API.
- Add "transparent" as color name for
Chroma.paint
. - Minor API doc example fixes.
- Add public API usage examples to README.
Bug Fixes:
- Fix bug where
Color#complement
didn't return a color of the same format. - Fix bug where palettes did not have the same format as the seed color. (#16)
- Fix bug where the helper method
bound01
was not always producing accurate results for percentages due to integer division. - Fix bug where a
Color
created from an rgba string (e.g.'rgba(255, 0, 0, 0.5).paint'
) was not serializing to an rgba string fromto_s
. (#17)
Method Changes:
- Add
Color#format
method to return@format
instance variable. - Change arguments for
analogous
andmonochromatic
to option arguments. - Add ability to output palette as an array of color format strings via the
:as
option. (#10) - On
Color
renamegreyscale
tograyscale
and aliasgreyscale
back tograyscale
.
Miscellaneous Changes:
- Introduced custom errors and replaced
raise
calls with them. - Added API doc headers. (#4)
Bug Fixes:
- Fixed bug with number of arguments passed to generator classes in RgbGenerator. (#1)
- Make
FromHexStringValues.from_hex8
take alpha as second parameter instead of last. Fixes incorrect color generation from hex8. (#6) - Ensure that string serialization rounds the alpha value where applicable. (#7)
- Fix bug where
to_s
andinspect
would return<unknown>
instead of using hex if the format was:name
and the named color could not be found. (#2) - Fix bug where
Color
equality wasn't implemented. (#12) - Fix bug where passing in an instance of
Hsl
orHsv
toColor.new
caused their values to get changed. (#11) - Fix bug with
Color
equality being off due to floating point math. (#13) - Fix bug where
Color
instances generated from hsla and hsva strings had the wrong alpha value. (#15)
Method Changes:
- Add optional
hex_for_unknown
parameter toColor::Serializers#to_name
. If true, it allowsto_name
to default to hex string if name is not found instead of returning'<unknown>'
. (#2) - Add missing conversion methods to converters (a12244f0d81c9480490cfb8a472993f54dd9fbd2)
- Add equality (
eql?
and==
) methods toColor
class andColorModes
classes. (#12, #13) - Add
Chroma.define_palette
for defining custom palettes. (#9) - Add
Color#paint
method for returning itself. (#14) - Tweak
Color
serialization method names. Switched to this naming primarily to drop the*_s
on the string serialization methods.to_hsv
->hsv
to_hsv_s
->to_hsv
to_hsl
->hsl
to_hsl_s
->to_hsl
to_hex
->to_basic_hex
(made private)to_hex_s
->to_hex
to_hex8
->to_basic_hex8
(made private)to_hex8_s
->to_hex8
to_rgb
->rgb
(moved attr_reader to serializers and made public)to_rgb_s
->to_rgb
- Removed
to_name_s
alias
- Initial release