JFee Posted July 14, 2008 Share Posted July 14, 2008 (edited) This is my first time posting a UDF, so here goes... muttley Returns the ControlID of a gradient graphic with dimensions $w by $h, at position $x, $y. The gradient is linear from $startColor to $endColor horizontally, unless $vertical = 1. You can choose the number of steps the gradient uses, but by default its is the length of the image. Hope you like it! Please let me know if there is anything that should be added or changed expandcollapse popupFunc _createGradient($startColor, $endColor, $w, $h, $x, $y, $iSteps = -1, $vertical = 0) If $iSteps = -1 And $vertical = 1 Then $iSteps = $h If $iSteps = -1 And $vertical = 0 Then $iSteps = $w $gradient = GUICtrlCreateGraphic($x, $y, $w, $h) $startColor = StringTrimLeft($startColor, 2) $endColor = StringTrimLeft($endColor, 2) $startRed = "0x" & StringLeft($startColor, 2) $startGreen = "0x" & StringMid($startColor, 3, 2) $startBlue = "0x" & StringRight($startColor, 2) $endRed = "0x" & StringLeft($endColor, 2) $endGreen = "0x" & StringMid($endColor, 3, 2) $endBlue = "0x" & StringRight($endColor, 2) For $x = 1 To $w For $y = 1 To $h GUICtrlSetGraphic($gradient, $GUI_GR_MOVE, $x, $y) If $vertical = 0 Then $currentStep = Int($x / $w * $iSteps) ElseIf $vertical = 1 Then $currentStep = Int($y / $h * $iSteps) Else Return 0 EndIf $stepRed = Hex($startRed + $currentStep * (($endRed - $startRed) / $iSteps), 2) $stepGreen = Hex($startGreen + $currentStep * (($endGreen - $startGreen) / $iSteps),2) $stepBlue = Hex($startBlue + $currentStep * (($endBlue - $startBlue) / $iSteps),2) $color = "0x" & $stepRed & $stepGreen & $stepBlue GUICtrlSetGraphic($gradient, $GUI_GR_COLOR, $color) GUICtrlSetGraphic($gradient, $GUI_GR_PIXEL, $x, $y) Next Next GUICtrlSetGraphic($gradient, $GUI_GR_REFRESH) Return $gradient EndFunc Edited July 14, 2008 by JFee Regards,Josh Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now