name22

Pseudorandom Color Transition

Jun 29th, 2011
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GDIP.au3>
  2.  
  3. ; - Author: name22 (www.autoit.de)
  4.  
  5. $hWnd = GUICreate("Example by name22", 400, 200)
  6.  
  7. $hWnd_Seed = GUICreate("Random Seed", 200, 60)
  8. $cInput_Seed = GUICtrlCreateInput("Seed", 5, 5, 190, 20)
  9. $cButton_Generate = GUICtrlCreateButton("Generate", 5, 30, 60, 25)
  10. $cButton_Go = GUICtrlCreateButton("Go", 70, 30, 60, 25)
  11. GUISetState(@SW_SHOW, $hWnd_Seed)
  12.  
  13. While True
  14.     Switch GUIGetMsg()
  15.         Case -3
  16.             Exit
  17.         Case $cButton_Generate
  18.             $iSeed = Random(0, 2 ^ 31 - 1, 1) * -1 ^ Random(1, 2, 1)
  19.             GUICtrlSetData($cInput_Seed, $iSeed)
  20.         Case $cButton_Go
  21.             $iSeed = GUICtrlRead($cInput_Seed)
  22.             If Int($iSeed) Or $iSeed = 0 And $iSeed >= -2 ^ 31 And $iSeed < 2 ^ 31 Then ExitLoop
  23.     EndSwitch
  24. WEnd
  25.  
  26. GUIDelete($hWnd_Seed)
  27.  
  28. SRandom($iSeed)
  29. $iARGB_Start = "0xFF" & Hex(Round(Random() * 0xFFFFFF), 6)
  30. $iARGB_End = "0xFF" & Hex(Round(Random() * 0xFFFFFF), 6)
  31.  
  32. GUISetState(@SW_SHOW, $hWnd)
  33.  
  34. _GDIPlus_Startup()
  35.  
  36. $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
  37. _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
  38. _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)
  39.  
  40. $hBrush = _GDIPlus_LineBrushCreate(0, 0, 400, 0, $iARGB_Start, $iARGB_End)
  41.  
  42. _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, 400, 200, $hBrush)
  43.  
  44. _GDIPlus_GraphicsDispose($hGraphics)
  45. _GDIPlus_BrushDispose($hBrush)
  46. _GDIPlus_Shutdown()
  47.  
  48. While GUIGetMsg() <> -3
  49. WEnd
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×