This code will create a gradient circle using the color, position, and radius that you want. (Currently only works on a VB form!!)
Code:
VB Code:
Public Function gradCircle(x, Y, circleRadius, colorRed, colorGreen, colorBlue, deForm As Form) 'Define some variables Dim cirStop As Integer cirStop = 50 'If function works fine, result is 0 gradCircle = 0 'Get color numbers (0-255) redColor = colorRed blueColor = colorBlue greenColor = colorGreen 'Get current AutoRedraw property defaultAutoRedraw = deForm.AutoRedraw 'Set AuroRedraw so circle can be created deForm.AutoRedraw = True 'Check for illegal numbers If redColor > 255 Or redColor < 0 Or blueColor > 255 Or blueColor < 0 Or greenColor > 256 Or greenColor < 0 Then gradCircle = 1 Exit Function End If If redColor >= blueColor And redColor >= greenColor Then topCol = redCol If blueColor >= redColor And blueColor >= greenColor Then topCol = blueCol If greenColor >= redColor And greenColor >= blueColor Then topCol = greenCol If topCol = 0 Then topCol = 255 'Obtain proper subtraction number for gradient If cirStop = 0 Then subBy = topCol / circleRadius Else subBy = cirStop / circleRadius End If 'Draw circle For i = 1 To circleRadius deForm.Circle (x, Y), i, RGB(redColor, greenColor, blueColor) 'Check if red has reached the stop number If redColor > cirStop Then redColor = redColor - subBy Else redDone = "yes" End If 'Check if blue has reached the stop number If blueColor > cirStop Then blueColor = blueColor - subBy Else blueDone = "yes" End If 'Check if green has reached the stop number If greenColor > cirStop Then greenColor = greenColor - subBy Else greenDone = "yes" End If 'If all colors have reached the stop number, exit loop If redDone = "yes" And blueDone = "yes" And greenDone = "yes" Then Exit For Next i 'Reset the AutoRedraw property to normal deForm.AutoRedraw = defaultAutoRedraw End Function
Usage:
VB Code:
Call gradCircle(xPosition, yPosition, Radius, RedRGB, GreenRGB, BlueRGB, theVBFormName)
This function will return '0' for a succesfull drawing and a '1' for a non-succesfull one.
If you modify this code please email me the new code at [email protected]
Cjqp




Reply With Quote