Jump to content

I can draw a heart shape with _GDIPlus ... ?


Recommended Posts

another small beating heart

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "Terminate")
Local $aHeart[2] = [35880831050934, 36163356196790], $side = 7, $aPixels[49], $iHeart, $iLoop
Global $hGui = GUICreate('', $side * 7, $side * 7, -1, -1, $WS_POPUPWINDOW, $WS_EX_DLGMODALFRAME + $WS_EX_TOPMOST)
For $i = 0 to 48
    $aPixels[$i] = GUICtrlCreateLabel('', $side * ($i - (Int($i / 7) * 7)), $side * Int($i / 7), $side, $side, -1, $GUI_WS_EX_PARENTDRAG)
Next
GUISetState()
While 1
    $iHeart = $aHeart[$iLoop]
    For $i = 0 To 48
        GUICtrlSetBkColor($aPixels[$i], 0xFF0000 + (Not Int(Mod($iHeart, 2)) * 0x00FFFF))
        $iHeart /= 2
    Next
    $iLoop = $iLoop = 0 = Sleep(500)
WEnd
Func Terminate()
    If WinActive($hGui) Then Exit
EndFunc   ;==>Terminate

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Beating ?   :D

#include <GUIConstantsEx.au3>
HotKeySet("{ESC}", "Terminate")

$hGui = GUICreate ( 'Draw Heart Example', 300, 300 )
GUICtrlSetDefColor(0xff0000, $hGui)
$h1 = GUICtrlCreateLabel(ChrW(9829), 12, -120, 300, 500)
GUICtrlSetFont(-1, 340, 400, 0, "Times New Roman")
$h2 = GUICtrlCreateLabel(ChrW(9829), 5, -128, 300, 500)
GUICtrlSetFont(-1, 290, 400, 0, "Arial Unicode MS")
GUISetState()

While 1
  GUICtrlSetState($h2, (BitAnd(GUICtrlGetState($h2), $GUI_SHOW) = $GUI_SHOW) ? $GUI_HIDE : $GUI_SHOW)
  Sleep(500)
WEnd

Func Terminate()
    If WinActive($hGui) Then Exit
EndFunc   ;==>Terminate

 

Edited by mikell
Link to comment
Share on other sites

simplified function

#Include <GDIPlus.au3>

Opt ( 'GUIOnEventMode', 1 )

Global $hGui, $hGraphic, $hBrush, $aPoints, $j = 1, $i = 8

$hGui = GUICreate ( 'Draw Heart Example', 500, 500 )
GUISetOnEvent ( -3, '_Exit' ) ; $GUI_EVENT_CLOSE
GUISetState()

_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ( $hGui )
$hBrush = _GDIPlus_BrushCreateSolid ( 0xFFFF0000 )

While 1
    $i += $j
    WinSetTitle ( $hGui, '', 'Draw Heart Example With ' & $i & ' Points' )
    $aPoints = _HeartGetPoints ( 40, 40, 420, 420, $i )
    _GDIPlus_GraphicsClear ( $hGraphic, 0xFFF4F4F4 )
    _GDIPlus_GraphicsFillPolygon ( $hGraphic, $aPoints, $hBrush )
    Sleep ( 250 -$i*2 )
    If $i = 60 Or $i = 8 Then
        $j = -$j
        Sleep ( 3000 )
    EndIf
WEnd

Func _HeartGetPoints ( $x=0, $y=0, $iWidth=100, $iHeight=100, $iPointCount=80 )
;~  If $iPointCount < 20 Then $iPointCount = 20
    Local $aPoints[$iPointCount+1][2], $k, $fPI = ACos( -1 )
    For $i = 0 To 2*$fPi Step ( 8/$iPointCount )*$fPi/4
        $k+=1
        If $k > UBound ( $aPoints ) -1 Then ExitLoop
        $aPoints[$k][0] = $x +( 16 -16*Sin( $i )^3 )*$iWidth/32
        $aPoints[$k][1] = $y +( 12 -( 13*Cos( $i ) -5*Cos( 2*$i ) -2*Cos( 3*$i ) -Cos( 4*$i ) ) )*$iHeight/28
    Next
    $aPoints[0][0] = UBound ( $aPoints ) -1
    Return $aPoints
EndFunc ;==> _HeartGetPoints()

Func _Exit()
    _GDIPlus_BrushDispose ( $hBrush )
    _GDIPlus_GraphicsDispose ( $hGraphic )
    _GDIPlus_Shutdown()
    GUIDelete ( $hGui )
    Exit
EndFunc ;==> _Exit()

 

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...