Color Shading

Blitz3D Forums/Blitz3D Beginners Area/Color Shading

I am trying to write a routine that creates "3d" buttons in 2d via a single function which is passed red, green and blue values. My intention is to have the function automatically generate the required colors to lighten the left/top edge and darken the bottom/right edge. I therefore need to be able to create any shade of a given color from very dark (almost black) to very light (almost white). Despite much brain cell scratching, I have not been able to achieve this. I have got this far, which does not work:

r#=5
g#=167
b#=119

rd#=r#/100
gd#=g#/100
bd#=b#/100

For k#=5 To 250 Step 5
	Color k#*rd#,k#*gd#,k#*bd#
	Rect x%,y%,32,32,1
	If k#=100 Then ; orig color
		Color 255,255,255
		Rect x%,y%,32,32,0
	EndIf
	x%=x%+32
	If x%=320 Then 
		x%=0
		y%=y%+32
	EndIf
Next

WaitKey
End


I am very new to working with color palettes - can anyone please give me any pointers as to what I am doing wrong?