What would be the code to make a gradient of:
Black -> AnyColor -> White
?
Printable View
What would be the code to make a gradient of:
Black -> AnyColor -> White
?
r=0
g=0
b=0
For n = 1 to 255
r = r + 1
g = g + 1
b = b + 1
next n
'this will do a fade, just use the rgb function to change the color of what u want to change.
I'm not that good with english. :(
what is a gradient??
If you mean a fading from one color to another, here's some code to fade the background of a form that might help you along the way
Wanna be helpful :)Code:'A background that fade's from blue to black
Private Sub Form_Paint()
Dim lY As Long
Dim lScaleHeight As Long
Dim lScaleWidth As Long
ScaleMode = vbPixels
lScaleHeight = ScaleHeight
lScaleWidth = ScaleWidth
DrawStyle = vbInvisible
FillStyle = vbFSSolid
For lY = 0 To lScaleHeight
FillColor = RGB(0, 0, 255 - (lY * 255) \ lScaleHeight)
Line (-1, lY - 1)-(lScaleWidth, lY + 1), , B
Next lY
'rgb(0,0,255 - (lY...) ' blue to black
'rgb(0,100,255 - (lY...) 'blue to green
'rgb(255,0,255 - (lY...) 'lightpink to red
'rgb(255,255,255 - (lY...)'white to yellow
'rgb(0,255,255 - (lY...) 'white to green
'rgb(255,100,255 - (lY...)'light pink to orange
'place the "255-(lY*255)\ lScaleHeight at the "R" or "G" to make
'it fade from another color
End Sub
------------------
On Error Goto Bed :0)
[email protected]
Well, yeah, I already know how to create my own gradients, thanks, I just want to know how to do the way I originally asked :)
This does what you want for red. You can use this as a template to do ‘any 1(R or G or B) color’. With a little Work you could make it work for any (R and G and B) color. You’d have to define the original ‘any’ color using RGB, create it by incrementing from RGB(0,0,0),and then when that color’s achieved increment all the values to RGB(255,255,255) .Simple enough?
Private Sub Form_Load()
Dim Red As Integer
AutoRedraw = True
For Red = 1 To 255
'increment red
R = R + 1
'use Red to create new x position
'then draw new colored line
xpos = Red * 10
Line (xpos, 0)-(xpos, 8000), RGB(R, B, G)
'If Red = 255 then Red is all done
'so increment Green + Blue untill 255
'RBG(255,255,255) = white
If R >= 255 Then
For G = 1 To 255
G = G + 1
B = G
'add new and last position to
xpos = (G * 10) + 2550
Line (xpos, 0)-(xpos, 8000), RGB(R, B,G)
Next
End If
Next
End Sub