Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get Hue/Sat/Lum
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00523566
Message ID:
00523590
Views:
9
Hi!

>How would I set get the Hue/Sat/Lum of the RGB() colors...

The code below converts red, gree, blue values to hue, sat, lum values:
red = 128
green = 192
blue = 255

vmin = min(red, green, blue)
vmax = max(red, green, blue)
delta = vmax - vmin
	
lum = vmax
if delta = 0
	hue = 0
	sat = 0
else
	temp = delta/vmax
	sat = temp*255

	if red = vmax
		temp = (green-blue)/delta
	else
		if green = vmax
			temp = 2 + (blue-red)/delta
		else
			temp = 4 + (red-green)/delta
		endif
		temp = temp * 60
		if temp < 0
			temp = temp + 360
		endif
		if temp = 360
			temp = 0
		endif
		hue = temp
	endif
endif

? hue, sat, lum
Previous
Reply
Map
View

Click here to load this message in the networking platform