Constructor
new (require("Color"))(red, green, blue, hexopt) → {Color}
- Source:
Set red, green and blue colors to create the Color object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
red |
Number | Red channel integer from 0 to 255 |
|
green |
Number | Green channel integer from 0 to 255 |
|
blue |
Number | Blue channel integer from 0 to 255 |
|
hex |
Number |
<optional> |
Optional hexadecimal color from 0x000000 to 0xFFFFFF |
Returns:
- Type
- Color
Methods
distance(color) → {Number}
- Source:
Distance between two colors.
- Minimum is 0 (between two same colors)
- Maximum is 1 (for example between black and white)
Parameters:
Name | Type | Description |
---|---|---|
color |
Color | Color to compare |
Returns:
- Type
- Number
getSaturation() → {Number}
- Source:
Saturation of the color from 0 to 1.
Returns:
- Type
- Number
getWeight(saturationImportance, maxCount) → {Number}
- Source:
Weight of the color depends of his saturation and his count.
Parameters:
Name | Type | Description |
---|---|---|
saturationImportance |
Number | Determine the weight of the saturation for the calcul (from 0 to 1) |
maxCount |
Number | Number of pixels in the image. |
Returns:
- Type
- Number