_HSB32
Jump to navigation
Jump to search
The _HSB32 function specifies a color using the HSB colorspace and returns the 32-bit ARGB color value representing the color with the specified hue, saturation and brightness.
Syntax
- color32value~& = _HSB32(hue#, saturation#, brightness#)
Parameters
- hue# specifies the hue DOUBLE of the desired color from 0 to 360 degrees.
- The color wheel starts with red(0), turns to yellow(60), green(120), cyan(180), blue(240), magenta(300) to red(360) again.
- Mixed colors can be build by specifying values between the 6 base color angles.
- saturation# specifies the saturation DOUBLE of the desired color from 0 to 100 percent.
- 100% is the richest color possible, as closer you come to 0%, as more the color is fading ending at dull gray.
- The intensity of the gray (i.e. black >> darkgray >> midgray >> lightgray >> white) depends on the brightness# value.
- brightness# specifies the brightness DOUBLE of the desired color from 0 to 100 percent.
- 100% is the brightest (highest intensity), as closer you come to 0%, as darker is the color always ending in black regardless of the given hue# and saturation#.
Description
- The value returned is always a 32-bit _UNSIGNED LONG ARGB color value, as is the POINT value.
- Return variable types must be _UNSIGNED LONG or LONG, otherwise the resulting color may lose the _BLUE value.
- Parameter values outside the allowed ranges are clipped.
- Returns _UNSIGNED LONG 32-bit hexadecimal values from &H00000000 to &HFFFFFFFF.
- When (_UNSIGNED) LONG values are PUT to file, the ARGB values become BGRA. Use LEFT$(MKL$(color32value~&), 3) to place 3 colors.
Availability
Examples
- Example 1
- Drawing a color wheel by looping through hue and saturation.
SCREEN _NEWIMAGE(640, 480, 32) FOR ang# = 0 TO 360 STEP 0.25 FOR rad# = 0 TO 200 STEP 0.25 x% = rad# * COS(_D2R(ang#)) y% = rad# * SIN(_D2R(ang#)) PSET (320 + x%, 240 - y%), _HSB32(ang#, rad# / 2, 100) NEXT rad# NEXT ang# END |
- Example 2
- Drawing a 3D model of the HSB colorspace with a cut to see inside.
SCREEN _NEWIMAGE(640, 480, 32) FOR hei# = 0 TO 200 STEP 5 FOR ang# = 5 TO 285 STEP 0.25 FOR rad# = 0 TO 200 STEP 1 x% = rad# * COS(_D2R(ang#)) y% = rad# * SIN(_D2R(ang#)) z% = hei# XYfrom3D x%, y%, z% PSET (330 + x%, -z% + 340), _HSB32(ang#, rad# / 2, hei# / 2) IF rad# = 0 _ANDALSO (hei# = 0 OR hei# = 200) THEN IF hei# = 0 THEN IF ang# = 5 THEN bmpx% = 330 + x%: bmpy% = -z% + 340 ELSE IF ang# = 5 THEN tmpx% = 330 + x%: tmpy% = -z% + 340 END IF ELSEIF rad# = 200 _ANDALSO (hei# = 0 OR hei# = 200) THEN PSET (330 + x%, -z% + 340), &HFFFFFFFF IF hei# = 0 THEN IF ang# = 5 THEN bspx% = 330 + x%: bspy% = -z% + 340 IF ang# = 285 THEN bepx% = 330 + x%: bepy% = -z% + 340 ELSE IF ang# = 5 THEN tspx% = 330 + x%: tspy% = -z% + 340 IF ang# = 285 THEN tepx% = 330 + x%: tepy% = -z% + 340 END IF END IF NEXT rad# NEXT ang# NEXT hei# LINE (bspx%, bspy%)-(bmpx%, bmpy%), &HFFFFFFFF LINE (bmpx%, bmpy%)-(bepx%, bepy%), &HFFFFFFFF LINE (tspx%, tspy%)-(tmpx%, tmpy%), &HFFFFFFFF LINE (tmpx%, tmpy%)-(tepx%, tepy%), &HFFFFFFFF LINE (bspx%, bspy%)-(tspx%, tspy%), &HFFFFFFFF LINE (bmpx%, bmpy%)-(tmpx%, tmpy%), &HFFFFFFFF LINE (bepx%, bepy%)-(tepx%, tepy%), &HFFFFFFFF END SUB XYfrom3D (x%, y%, z%) x% = (x% + (y% * .5)) z% = (z% + (y% * .5)) END SUB |
See also
- _HSBA32, _HUE32
- _SATURATION32, _BRIGHTNESS32
- _RGBA32, _RGB, _RGBA
- _RED32, _GREEN32, _BLUE32
- _PALETTECOLOR
- HEX$ 32 Bit Values
- SaveImage SUB
- Hexadecimal Color Values