Skip to content

Instantly share code, notes, and snippets.

@turbo
Created May 15, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turbo/8b2d78b232b9f8186a03 to your computer and use it in GitHub Desktop.
Save turbo/8b2d78b232b9f8186a03 to your computer and use it in GitHub Desktop.
PolyPlay: A nice GDI effect.
Opt("GUIOnEventMode", 1)
; Start messing around = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Local $ForeRed = 0, $ForeGreen = 0, $ForeBlue = 0 ; Color 1
Local $BackRed = 255, $BackGreen = 0, $BackBlue = 0 ; Color 2
Local $AntiAliasing = 1 ; Antialiasing (kind of...)
Local $RotRange = 100 ; rotation
; Stop messing around! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
$hGUI = GUICreate("PolyPlay | FPS: 0",500,500,-1,-1,Default,34078728)
GUISetBkColor(0)
Global $hGraphics = GUICtrlCreateGraphic(0,0)
GUISetOnEvent(-3, "done")
GUISetState()
AdlibRegister("FPS", 1000)
Local $r = -$RotRange, $modificator = 1, $iFPS = 0
While 1
$r += $modificator
If $r > $RotRange Or $r < -$RotRange Then $modificator *= -1
Draw($ForeRed, $ForeGreen, $ForeBlue, $BackRed, $BackGreen, $BackBlue, $r, 100 * $AntiAliasing)
$iFPS += 1
WEnd
Func Draw($FRed, $FGreen, $FBlue, $BRed, $BGreen, $BBlue, $Rotate, $Step)
$old = $hGraphics
$hGraphics = GUICtrlCreateGraphic(0,0)
Local $ROffSet=($BRed-$FRed)/$Step,$GOffset=($BGreen-$FGreen)/$Step,$BOffset=($BBlue-$FBlue)/$Step,$XOffset=250/$Step,$YOffset=250/$Step
Local $RotateOffset = $Rotate / $Step
Dim $T
For $T = 0 To $Step
$Color = RGB($FRed+($T*$ROffSet),$FGreen+($T*$GOffset),$FBlue+($T*$BOffset))
GUICtrlSetGraphic($hGraphics,8,$Color,$Color)
GUICtrlSetGraphic($hGraphics,6,250+X(-(250-($T*$XOffset)),-(250-($T*$YOffset)),$RotateOffset*$T),250+Y(-(250-($T*$XOffset)),-(250-($T*$YOffset)),$RotateOffset*$T))
GUICtrlSetGraphic($hGraphics,2,250+X( (250-($T*$XOffset)),-(250-($T*$YOffset)),$RotateOffset*$T),250+Y( (250-($T*$XOffset)),-(250-($T*$YOffset)),$RotateOffset*$T))
GUICtrlSetGraphic($hGraphics,2,250+X( (250-($T*$XOffset)), (250-($T*$YOffset)),$RotateOffset*$T),250+Y( (250-($T*$XOffset)), (250-($T*$YOffset)),$RotateOffset*$T))
GUICtrlSetGraphic($hGraphics,2,250+X(-(250-($T*$XOffset)), (250-($T*$YOffset)),$RotateOffset*$T),250+Y(-(250-($T*$XOffset)), (250-($T*$YOffset)),$RotateOffset*$T))
Next
GUICtrlSetGraphic($hGraphics, 22)
GUICtrlDelete($old)
EndFunc
Func RGB($r, $g, $b)
Return "0x" & Hex(Int($r), 2) & Hex(Int($g), 2) & Hex(Int($b), 2)
EndFunc
Func X($RX, $RY, $ZAn)
$TZAn = $ZAn * (3.141592654 / 180)
Return $RX * Cos($TZAn) - $RY * Sin($TZAn)
EndFunc
Func Y($RX, $RY, $ZAn)
$TZAn = $ZAn * (3.141592654 / 180)
Return $RY * Cos($TZAn) + $RX * Sin($TZAn)
EndFunc
Func FPS()
WinSetTitle("", "", "PolyPlay | FPS: " & $iFPS)
$iFPS = 0
EndFunc
Func done()
Exit
EndFunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment