README.md in decolmor-1.0.0 vs README.md in decolmor-1.1.0
- old
+ new
@@ -1,11 +1,11 @@
# Decolmor
-[](http://badge.fury.io/rb/decolmor)
+[](https://badge.fury.io/rb/decolmor)
[](https://app.travis-ci.com/ChildrenofkoRn/decolmor)
[](https://codecov.io/gh/ChildrenofkoRn/decolmor)
-Gem for converting the color spaces from/to: HEX/RGB/HSL/HSV/HSB/CMYK
+Gem for converting color spaces from/to: HEX/RGB/HSL/HSV/HSB/CMYK
The Alpha channel (transparency) is supported.
There is also a simple RGB generator.
## Install
Add the following line to Gemfile:
@@ -44,10 +44,11 @@
hsv = Decolmor::rgb_to_hsv(rgb) # => [327.8, 89.7, 87.8]
Decolmor::hsv_to_rgb(hsv) # => [224, 23, 131]
Decolmor::hsl_to_rgb(hsl) # => [224, 23, 131]
```
If you convert between HSL <==> HSV (HSB) with a rounding of 2, you can get more accurate results.
+This can also be useful if you use HSL/HSB for intermediate changes and then go back to RGB.
You can change rounding globally:
```ruby
Decolmor::hsx_round = 2
Decolmor::rgb_to_hsl(rgb) # => [154.55, 63.06, 30.78]
Decolmor::hsx_round # => 2
@@ -56,17 +57,28 @@
```ruby
Decolmor::rgb_to_hsl(rgb, 3) # => [154.545, 63.057, 30.784]
```
In this case, the global rounding will be ignored.
If you need to get integers, use 0.
-
+
+## HEX to RGB(A)
+ - with & without prefix `#`
+ - short HEX are supported (including Alpha)
+ - can be set rounding for the Alpha channel
+
## Alpha channel
-When converting from HEX to RGBA Alpha channel is converted to a value from the range `0..1` with rounding 5:
+When converting from HEX to RGBA Alpha channel is converted to a value from the range `0..1` with rounding 3:
+ - 3 digits is enough for a lossless conversion `0..255` -> `0..1` -> `0..255`
```ruby
- Decolmor::hex_to_rgb('#19988BB8') # => [25, 152, 139, 0.72157]
+ Decolmor::hex_to_rgb('#19988BB8') # => [25, 152, 139, 0.722]
```
Consequently, when converting to HEX from RGBA, Alpha from the range `0..1` is assumed.
+You can also set rounding for Alpha channel as a second argument:
+```ruby
+ Decolmor::hex_to_rgb('#19988BB8', 2) # => [25, 152, 139, 0.72]
+```
+This only works for converting HEX to RGBA.
In other cases (conversions between RGB/HSL/HSV/HSB/CMYK) Alpha channel remains unchanged.
## HSV or HSB
HSB is an alternative name for HSV, it is the same thing.
However, for convenience, aliasing methods are made for HSB from HSV.
@@ -98,10 +110,10 @@
Read more: https://en.wikipedia.org/wiki/HSL_and_HSV
The results when rounded to an integer will be the same as when using graphics editors, such as CorelDRAW or Adobe Photoshop.
## Supported Methods
- Setter global rounding for conversion to HSL/HSV/HSB/CMYK
- - Decolmor::hsx_round =
+ - hsx_round =
- HEX <==> RGB(A)
- hex_to_rgb
- rgb_to_hex
- Simple generator RGB, you can set any channel(s)
- new_rgb