AustrianOak Posted July 10, 2008 Share Posted July 10, 2008 Is there a way to add a gradient on a label using two colors. Link to comment Share on other sites More sharing options...
AustrianOak Posted July 12, 2008 Author Share Posted July 12, 2008 bump. lost on this one... Link to comment Share on other sites More sharing options...
AustrianOak Posted July 14, 2008 Author Share Posted July 14, 2008 ~bump~ Link to comment Share on other sites More sharing options...
JFee Posted July 14, 2008 Share Posted July 14, 2008 Not that I know of. You can easily make a graphic control with a gradient if you don't want to use an image. To make a graphic, do something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> GUICreate("Gradient", 200, 200) GUISetState() ; The color at the beginning, 0xFFFFFF $startRed = 0xFF $startGreen = 0xFF $startBlue = 0xFF ; The color at the end, 0x000000 $endRed = 0x00 $endGreen = 0x00 $endBlue = 0x00 ; Number of steps in the gradient $steps = 100 ; Width/Height of gradient $width = 100 $height = 50 $gradient = GUICtrlCreateGraphic(0, 0, $width, $height) For $x = 1 To $width For $y = 1 To $height GUICtrlSetGraphic($gradient, $GUI_GR_MOVE, $x, $y) $currentStep = ($x / $width) * $steps $stepRed = Hex(($endRed - $startRed) + $currentStep * ($endRed - $startRed / $steps), 2) $stepGreen = Hex(($endGreen - $startGreen) + $currentStep * ($endGreen - $startGreen / $steps),2) $stepBlue = Hex(($endBlue - $startBlue) + $currentStep * ($endBlue - $startBlue / $steps),2) $color = "0x" & $stepRed & $stepGreen & $stepBlue GUICtrlSetGraphic($gradient, $GUI_GR_COLOR, $color) GUICtrlSetGraphic($gradient, $GUI_GR_PIXEL, $x, $y) Next ;MsgBox(1, "", $color) Next While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd Basically you just use a percent complete ($currentstep) to find out how much color to add to each value, red green and blue. Only downside is that graphic controls suck muttley Regards,Josh Link to comment Share on other sites More sharing options...
AustrianOak Posted July 14, 2008 Author Share Posted July 14, 2008 I don't see anything in the gui? Link to comment Share on other sites More sharing options...
JFee Posted July 14, 2008 Share Posted July 14, 2008 Haha, my bad... forgot to have it refresh the graphic (hence why graphics suck)... use this code: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> GUICreate("Gradient", 200, 200) GUISetState() ; The color at the beginning, 0xFFFFFF $startRed = 0xFF $startGreen = 0xFF $startBlue = 0xFF ; The color at the end, 0x000000 $endRed = 0x00 $endGreen = 0x00 $endBlue = 0x00 ; Number of steps in the gradient $steps = 10 ; Width/Height of gradient $width = 100 $height = 50 $gradient = GUICtrlCreateGraphic(0, 0, $width, $height) For $x = 1 To $width For $y = 1 To $height GUICtrlSetGraphic($gradient, $GUI_GR_MOVE, $x, $y) $currentStep = ($x / $width) * $steps $stepRed = Hex(($endRed - $startRed) + $currentStep * (($endRed - $startRed) / $steps), 2) $stepGreen = Hex(($endGreen - $startGreen) + $currentStep * (($endGreen - $startGreen) / $steps),2) $stepBlue = Hex(($endBlue - $startBlue) + $currentStep * (($endBlue - $startBlue) / $steps),2) $color = "0x" & $stepRed & $stepGreen & $stepBlue GUICtrlSetGraphic($gradient, $GUI_GR_COLOR, $color) GUICtrlSetGraphic($gradient, $GUI_GR_PIXEL, $x, $y) Next ;MsgBox(1, "", $color) Next GUICtrlSetGraphic($gradient, $GUI_GR_REFRESH) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd For some reason the number of steps aren't working... not a big deal though... you should always want best resolution if unless you don't want a smooth gradient Regards,Josh Link to comment Share on other sites More sharing options...
AustrianOak Posted July 14, 2008 Author Share Posted July 14, 2008 Ok thanks. Is this the only way to make a gradient? How come I've seen other programs do it perfectly, and is this just an autoit limit? Link to comment Share on other sites More sharing options...
JFee Posted July 14, 2008 Share Posted July 14, 2008 I'm sure there are other ways. I just use that when I need to, but I think you can do a similar process with GDIPlus. What other programs do you speak of? They could be using an image... Regards,Josh Link to comment Share on other sites More sharing options...
ChrisL Posted July 14, 2008 Share Posted July 14, 2008 Or take JFee's cool idea and turn it into a single UDF for creating a gradient label... expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> GUICreate("Gradient", 200, 200) $label1 = _GuiCtrlCreateGradientLabel("Test text on label",0,0,100,50,0,0,0,255,255,255) $label2 = _GuiCtrlCreateGradientLabel("Test text on label2",0,50,100,50,0,255,0,255,200,0) $Label3 = _GuiCtrlCreateGradientLabel("Test text on label2",0,100,100,50,255,0,0,0,0,255) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd Func _GuiCtrlCreateGradientLabel($vText,$x,$y,$w,$h,$RStart,$GStart,$BStart,$REnd,$GEnd,$BEnd,$iSteps = 10) $gradient = GUICtrlCreateGraphic($x, $y, $w, $h) For $iX = 1 To $w For $iY = 1 To $h GUICtrlSetGraphic($gradient, $GUI_GR_MOVE, $iX, $iY) $currentStep = ($iX / $w) * $iSteps $stepRed = Hex(($REnd - $RStart) + $currentStep * (($REnd - $RStart) / $iSteps), 2) $stepGreen = Hex(($GEnd - $GStart) + $currentStep * (($GEnd - $GStart) / $iSteps),2) $stepBlue = Hex(($BEnd - $BStart) + $currentStep * (($BEnd - $BStart) / $iSteps),2) $color = "0x" & $stepRed & $stepGreen & $stepBlue GUICtrlSetGraphic($gradient, $GUI_GR_COLOR, $color) GUICtrlSetGraphic($gradient, $GUI_GR_PIXEL, $iX, $iY) Next Next GUICtrlSetGraphic($gradient, $GUI_GR_REFRESH) $hLabel = GuiCtrlCreateLabel($vText,$x,$y,$w,$h) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
JFee Posted July 14, 2008 Share Posted July 14, 2008 I like it Remind me to save this one so I don't have to remember how to do it again muttley I think I'm going to see if I can make it better with GDIPlus. Regards,Josh Link to comment Share on other sites More sharing options...
Marcelos Posted December 19, 2013 Share Posted December 19, 2013 Hi using labels you can create a gradient band . you cant use text , but is a nice touch $intervalos=6 $lblwidth=$popupwidth-10 $clrs=StringSplit("0x990066,0x990077,0x990088,0x990099,0x9900aa,0x9900bb",",") $lbltop=0 $lblhigh=0 ;-- For $i=1 to UBound($clrs)-1 $lbltop=$lblhigh $lblhigh=$lblhigh+$popupheight/$intervalos GUICtrlCreateLabel("", $lblwidth, $lbltop, 10, $popupheight) GUICtrlSetBkColor(-1,$clr[$i]) next Graphical Control - Week Planner Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2013 Moderators Share Posted December 19, 2013 Marcelos,You do realise this thread was last active 5 1/2 years ago? Please do not necro-post like this in future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts