SATURATION32: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
(Created page with "{{DISPLAYTITLE:_SATURATION32}} The _SATURATION32 function returns the saturation value ([https://www.learnui.design/blog/the-hsb-color-system-practicioners-primer.html HSB colorspace]) of a given 32-bit ''ARGB'' color. {{PageSyntax}} : {{Parameter|saturation#}} = _SATURATION32({{Parameter|argbColor~&}}) {{PageParameters}} * {{Parameter|argbColor~&}} is the 32-bit ''ARGB'' color value to retrieve the saturation value from. ** ''ARGB'' colors are returned by va...") |
No edit summary |
||
Line 22: | Line 22: | ||
:* When converting between colorspaces, rounding errors can occur. While the HSB colorspace has virtually infinite precision only limited by the used floating point type, RGB is represented in 8-bit integers (0-255) only, which can lead to quantization errors. In fact, not all colors in HSB can be accurately represented in RGB and vice versa. | :* When converting between colorspaces, rounding errors can occur. While the HSB colorspace has virtually infinite precision only limited by the used floating point type, RGB is represented in 8-bit integers (0-255) only, which can lead to quantization errors. In fact, not all colors in HSB can be accurately represented in RGB and vice versa. | ||
:* However, if you limit yourself to only passing integer values to [[_HSB32]] or [[_HSBA32]], just as you do for the respective RGB colorspace functions [[_RGB32]] or [[_RGBA32]], then you can get back that exact values by [[CINT]]ing the results returned by [[_HUE32]], [[_SATURATION32]] and [[_BRIGHTNESS32]]. | :* However, if you limit yourself to only passing integer values to [[_HSB32]] or [[_HSBA32]], just as you do for the respective RGB colorspace functions [[_RGB32]] or [[_RGBA32]], then you can get back that exact values by [[CINT]]ing the results returned by [[_HUE32]], [[_SATURATION32]] and [[_BRIGHTNESS32]]. | ||
{{PageAvailability}} | |||
<!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no --> | |||
<gallery widths="48px" heights="48px" mode="nolines"> | |||
File:Qb64.png|'''none''' | |||
File:Qbpe.png|'''v4.0.0''' | |||
File:Apix.png | |||
File:Win.png|'''yes''' | |||
File:Lnx.png|'''yes''' | |||
File:Osx.png|'''yes''' | |||
</gallery> | |||
<!-- additional availability notes go below here --> | |||
Revision as of 19:49, 3 December 2024
The _SATURATION32 function returns the saturation value (HSB colorspace) of a given 32-bit ARGB color.
Syntax
- saturation# = _SATURATION32(argbColor~&)
Parameters
- argbColor~& is the 32-bit ARGB color value to retrieve the saturation value from.
Description
- The value returned is of type DOUBLE in the range 0 to 100 percent, use CINT to work with integers only.
- 100% is the richest color possible, as closer the value comes to 0%, as more faded is the color, ending at dull gray.
- The intensity of the gray (i.e. black >> darkgray >> midgray >> lightgray >> white) depends on the brightness value.
- Naming differences
-
- The HSB (B=Brightness) colorspace is also known as HSV (V=Value) and sometimes even called HSI (I=Intensity), but that's all just different names for the same thing.
- However, this function is not suitable for the HSL (L=Lightness) colorspace, which is widely used in the Web/CSS.
- Precision drawbacks
-
- When converting between colorspaces, rounding errors can occur. While the HSB colorspace has virtually infinite precision only limited by the used floating point type, RGB is represented in 8-bit integers (0-255) only, which can lead to quantization errors. In fact, not all colors in HSB can be accurately represented in RGB and vice versa.
- However, if you limit yourself to only passing integer values to _HSB32 or _HSBA32, just as you do for the respective RGB colorspace functions _RGB32 or _RGBA32, then you can get back that exact values by CINTing the results returned by _HUE32, _SATURATION32 and _BRIGHTNESS32.
Availability
Examples
PRINT "Creating a color using the HSB colorspace..." c~& = _HSB32(90, 75, 65) PRINT "_HSB32( 90, 75, 65 ) = _RGB32("; _RED32(c~&); ","; _GREEN32(c~&); ","; _BLUE32(c~&); ")" PRINT PRINT "back to HSB values (notice the precision loss)..." PRINT "Hue.......:"; _HUE32(c~&) PRINT "Saturation:"; _SATURATION32(c~&) PRINT "Brightness:"; _BRIGHTNESS32(c~&) PRINT PRINT "but with CINT() we can get back the original values..." PRINT "Hue.......:"; CINT(_HUE32(c~&)) PRINT "Saturation:"; CINT(_SATURATION32(c~&)) PRINT "Brightness:"; CINT(_BRIGHTNESS32(c~&)) END |
See also