Jump to content

Some Graphical Examples using GDI+ Vol. I


UEZ
 Share

Recommended Posts

Thanks for the examples.

Just messing around. A little to slow for full-screen screensaver I'm afraid.

Looks really nice - thanks for posting your example to this thread!

Regards,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Very exciting! It seems very difficult for me to understand the mathematic algorithms because I'm only a 10th grader in VietNam. :idea:. 5 star!

It quite slow in Win2000 machine too.

Edited by logmein
Link to comment
Share on other sites

Your programs are fascinating and I will look at them to learn things when I need. "Rotating Letters Transparent" has a memory leak, I guess the creates and disposes don't match. Best regards.

Indeed, I've forgotten to update the old version which has a memory leak! :idea:

Btw, proper working version was in the AiO download archive...

Thanks for the hint!

Bump:

@UEZ: I changed the Title to "Lingering Line". "Radical Radius" was leftover from someone else his script.

(This message will self destruct)

Changed. :)

BR,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 4 months later...

Great GDI+ examples UEZ (and others) ;)

Now a favour...

Every so often I try to get my head around the 3D vector stuff, I`ve tried playing with the cube code, but really need a simpler example, kinda like this 3D vector example

but simpler with just X,Y and Z arrows, i.e three lines from the origin.

(in the video, Z is pointing up, which does not make sense to me, X = across, Y = up like in a graph, while z is "depth")

Many thanks.

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

You mean this:

;coded by UEZ 2010
#include <GDIPlus.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 1)

Local Const $Width = 600
Local Const $Height = $Width

Local $hwnd = GUICreate("GDI+: 3D Axis by UEZ 2010 (use mouse wheel to zoom)", $Width, $Height)

GUISetState()

If @OSBuild < 7600 Then WinSetTrans($hwnd,"", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsClear($hBackbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

Local $pColor = 0xFF0000F0
Local $hPen = _GDIPlus_PenCreate($pColor, 3)
Local Const $length = 250
Local Const $Pi = ACos(-1)
Local Const $amout_of_dots = 6
Local $draw_coordinates[$amout_of_dots][4] = [ _;   X                   y                   Z
                                                [-$length,          0,              0   ], _
                                                [$length,               0,                  0   ], _
                                                [0,          -$length,          0   ], _
                                                [0,              $length,           0   ], _
                                                [0,                     0,       -$length   ], _
                                                [0,                     0,       $length    ]]

Local $x1, $y1, $x2, $y2
Local $b, $j, $x, $y, $z, $mx, $my, $mouse_pos
Local $zoom_counter = 100
Local Const $zoom_min = 50
Local Const $zoom_max = 125
Local Const $mouse_sense = 4000
Local Const $start_x = $Width / 2
Local Const $start_y = $Height / 2
Local Const $dx = @DesktopWidth / 2, $dy = @DesktopHeight / 2


MouseMove($dx, $dy, 1)

GUIRegisterMsg(0x020A, "WM_MOUSEWHEEL")

GUISetOnEvent(-3, "Close")

Do
    _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF)

    For $b = 0 To $amout_of_dots - 1 ;correct perspective
        $draw_coordinates[$b][3] = 1 + $draw_coordinates[$b][2] / 1500
    Next
    ;draw lines
    Draw_Lines(0, 1, 0xFFF00000) ;draw x axis - red
    Draw_Lines(2, 3, 0xFF00F000) ;draw y axis - green
    Draw_Lines(4, 5, 0xFF0000F0) ;draw z axis - blue

    $mouse_pos = MouseGetPos()
    For $j = 0 To $amout_of_dots - 1
        Calc(-(-$dy + $mouse_pos[1]) / $mouse_sense, (-$dx + $mouse_pos[0]) / $mouse_sense, $j) ;calculate new coordinates
    Next

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $Width, $Height)
Until Not Sleep(30)

Func Draw_Lines($p1, $p2, $pColor = 0xFF0000F0)
    $x1 = $start_x + $draw_coordinates[$p1][0] * $draw_coordinates[$p1][3]
    $y1 = $start_y + $draw_coordinates[$p1][1] * $draw_coordinates[$p1][3]
    $x2 = $start_x + $draw_coordinates[$p2][0] * $draw_coordinates[$p2][3]
    $y2 = $start_y + $draw_coordinates[$p2][1] * $draw_coordinates[$p2][3]
    _GDIPlus_PenSetColor($hPen, $pColor)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x1, $y1, $x2, $y2, $hPen)
EndFunc ;==>Draw

Func Calc($angle_x, $angle_y, $i, $angle_z = 0)
    ;calculate 3D rotation
    $x = $draw_coordinates[$i][0] * Cos($angle_y) + $draw_coordinates[$i][2] * Sin($angle_y)
    $y = $draw_coordinates[$i][1]
    $z = -$draw_coordinates[$i][0] * Sin($angle_y) + $draw_coordinates[$i][2] * Cos($angle_y)
    $draw_coordinates[$i][0] = $x
    $draw_coordinates[$i][1] = $y * Cos($angle_x) - $z * Sin($angle_x)
    $draw_coordinates[$i][2] = $y * Sin($angle_x) + $z * Cos($angle_x)
EndFunc ;==>Calc

Func Close()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc ;==>Close

Func Zoom($factor)
    Local $m
    For $m = 0 To $amout_of_dots - 1
        $draw_coordinates[$m][0] *= $factor
        $draw_coordinates[$m][1] *= $factor
        $draw_coordinates[$m][2] *= $factor
    Next
EndFunc

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    Local $wheel_Dir = BitAND($wParam, 0x800000)
    If $wheel_Dir > 0 Then
        If $zoom_counter <= $zoom_max Then
            Zoom(1.05)
            $zoom_counter += 1
        EndIf
    Else
        If $zoom_counter >= $zoom_min Then
            Zoom(0.95)
            $zoom_counter -= 1
        EndIf
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_MOUSEWHEEL

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I can`t work out how the angles are calculated from the mouse movement, you are not using the Pi constant....

I want to be able to rotate each axis by using the cursor keys (or sliders) and display the angle each axis has been rotated.

Here what I have so far...

#include <GDIPlus.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 1)

Local Const $Width = 600
Local Const $Height = $Width

Local $hwnd = GUICreate("GDI+: 3D Axis by UEZ 2010 (use mouse wheel to zoom)", $Width, $Height)

GUISetState()

If @OSBuild < 7600 Then WinSetTrans($hwnd,"", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsClear($hBackbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

Local $Str
Local $pColor = 0xFF0000F0
Local $hPen = _GDIPlus_PenCreate($pColor, 3)
Local $hBrush = _GDIPlus_BrushCreateSolid ()
Local Const $length = 250
Local Const $Pi = ACos(-1)
Local Const $amout_of_dots = 6
Local $draw_coordinates[$amout_of_dots][4] = [ _;   X                   y                   Z
                                                [-$length,              0,                  0   ], _
                                                [$length,               0,                  0   ], _
                                                [0,                     -$length,           0   ], _
                                                [0,                     $length,            0   ], _
                                                [0,                     0,                  -$length   ], _
                                                [0,                     0,                  $length    ]]

Local $x1, $y1, $x2, $y2
Local $b, $j, $x, $y, $z, $mx, $my, $mouse_pos
Local $zoom_counter = 100
Local Const $zoom_min = 50
Local Const $zoom_max = 125
Local Const $mouse_sense = 4000
Local Const $start_x = $Width / 2
Local Const $start_y = $Height / 2
Local Const $dx = @DesktopWidth / 2, $dy = @DesktopHeight / 2
Local Const $Red    = 0xFFF00000
Local Const $Green  = 0xFF00F000
Local Const $Blue   = 0xFF0000F0

MouseMove($dx, $dy, 1)

GUIRegisterMsg(0x020A, "WM_MOUSEWHEEL")

GUISetOnEvent(-3, "Close")

Do
    _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF)

    For $b = 0 To $amout_of_dots - 1 ;correct perspective
        $draw_coordinates[$b][3] = 1 + $draw_coordinates[$b][2] / 1500
    Next
    ;draw lines
    Draw_Lines(0, 1, $Red)      ;draw x axis - red
    Draw_Lines(2, 3, $Green)    ;draw y axis - green
    Draw_Lines(4, 5, $Blue)     ;draw z axis - blue

    $mouse_pos = MouseGetPos()
    For $j = 0 To $amout_of_dots - 1
        $My = (-$dy + $mouse_pos[1]) / $mouse_sense
        $Mx = (-$dx + $mouse_pos[0]) / $mouse_sense

        ToolTip("AngleX = " &$Mx &" AngleY = " &$My, $mouse_pos[0]+10, $mouse_pos[1]+10)
        Calc($My, $Mx, $j) ;calculate new coordinates
    Next

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $Width, $Height)
Until Not Sleep(30)

Func Draw_Lines($p1, $p2, $pColor)
    $x1 = $start_x
    $y1 = $start_y
    #cs
    $x1 = $start_x + $draw_coordinates[$p1][0] * $draw_coordinates[$p1][3]
    $y1 = $start_y + $draw_coordinates[$p1][1] * $draw_coordinates[$p1][3]
    #ce
    $x2 = $start_x + $draw_coordinates[$p2][0] * $draw_coordinates[$p2][3]
    $y2 = $start_y + $draw_coordinates[$p2][1] * $draw_coordinates[$p2][3]

    _GDIPlus_PenSetColor($hPen, $pColor)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x1, $y1, $x2, $y2, $hPen)

;   _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $x2 - 15, $y2 - 15 , 30, 30, $hPen)
     _GDIPlus_BrushSetSolidColor($hBrush, $pColor)
    _GDIPlus_GraphicsFillEllipse($hBackbuffer,  $x2 - 15, $y2 - 15 , 30, 30, $hBrush)

Select
    Case $pColor = $Red
        $Str = "XAngle = "
        Case $pColor = $Green
        $Str = "YAngle = "
        Case $pColor = $Blue
        $Str = "ZAngle = "
EndSelect
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $Start_X - 10, $Start_Y - 10, 20, 20, 0) ; Origin
    _GDIPlus_GraphicsDrawString ($hBackbuffer, "Origin", $Start_X - 20, $Start_Y - 30)
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Str, $x2 - 20, $y2 - 30)

EndFunc ;==>Draw

Func Calc($angle_x, $angle_y, $i, $angle_z = 0)
    ;calculate 3D rotation
    $x =  $draw_coordinates[$i][0] * Cos($angle_y) + $draw_coordinates[$i][2] * Sin($angle_y)
    $y =  $draw_coordinates[$i][1]
    $z = -$draw_coordinates[$i][0] * Sin($angle_y) + $draw_coordinates[$i][2] * Cos($angle_y)

    $draw_coordinates[$i][0] = $x
    $draw_coordinates[$i][1] = $y * Cos($angle_x) - $z * Sin($angle_x)
    $draw_coordinates[$i][2] = $y * Sin($angle_x) + $z * Cos($angle_x)
EndFunc ;==>Calc

Func Close()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc ;==>Close

Func Zoom($factor)
    Local $m
    For $m = 0 To $amout_of_dots - 1
        $draw_coordinates[$m][0] *= $factor
        $draw_coordinates[$m][1] *= $factor
        $draw_coordinates[$m][2] *= $factor
    Next
EndFunc

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    Local $wheel_Dir = BitAND($wParam, 0x800000)
    If $wheel_Dir > 0 Then
        If $zoom_counter <= $zoom_max Then
            Zoom(1.05)
            $zoom_counter += 1
        EndIf
    Else
        If $zoom_counter >= $zoom_min Then
            Zoom(0.95)
            $zoom_counter -= 1
        EndIf
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_MOUSEWHEEL

Quick 2D example...

#include <GUIConstants.au3>
#include <GDIplus.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
$SliderGui = GUICreate("Move Slider to change Angle", 288, 63, 195, 335)
$Slider = GUICtrlCreateSlider(12, 18, 255, 23)
GUICtrlSetLimit($Slider, 360, 1)
GUISetState(@SW_SHOW)

Global Const $width     = 350
Global Const $height    = 300
Global $title = "GDI+ Double Buffer"

Global Const $nPI            = 3.1415926535897932384626433832795

Global $iRadius   = 120
Global $iCenter   = 150
Global $iSize     = 10
Global $iX1, $iY1, $iN ,$Rad,$iT,$R

Opt("GUIOnEventMode", 1)
$hwnd = GUICreate($title, $width, $height)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()

If @OSBuild < 7600 Then WinSetTrans($hwnd,"", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

Local $pColor = 0xFF0000F0
Local $hPen = _GDIPlus_PenCreate($pColor, 3)

_GDIPlus_GraphicsClear($hBackbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

While 1
            $Deg = GUICtrlRead($Slider)
;   For $Deg = 0 to 360 step 5
        _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF)
        $R = ($nPI / 2) - ($Deg  * ($nPI /180))
        $iX1 = $iCenter + Cos($R) * $iRadius
        $iY1 = $iCenter - Sin($R) * $iRadius
        _GDIPlus_GraphicsDrawLine($hBackbuffer, $iCenter, $iCenter, $iX1, $iY1, 0)
        _GDIPlus_GraphicsDrawString ($hBackbuffer, "Angle = " &$Deg, $iX1, $iY1)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $width, $height)
    Sleep(100)
;  next

WEnd

Func close()
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_BitmapDispose  ($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc ;==>close

Thanks.

Edited by Lakes

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

I can`t work out how the angles are calculated from the mouse movement, you are not using the Pi constant....

...

I've to investigate how to calculate angles in 3D ;) but for 2D have a look here: Trigonometrie

好强大的代码啊,谢谢楼主分享 ;)

What?:)

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 2 weeks later...

I can`t work out how the angles are calculated from the mouse movement, you are not using the Pi constant....

I want to be able to rotate each axis by using the cursor keys (or sliders) and display the angle each axis has been rotated.

Here what I have so far...

#include <GDIPlus.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 1)

Local Const $Width = 600
Local Const $Height = $Width

Local $hwnd = GUICreate("GDI+: 3D Axis by UEZ 2010 (use mouse wheel to zoom)", $Width, $Height)

GUISetState()

If @OSBuild < 7600 Then WinSetTrans($hwnd,"", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsClear($hBackbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

Local $Str
Local $pColor = 0xFF0000F0
Local $hPen = _GDIPlus_PenCreate($pColor, 3)
Local $hBrush = _GDIPlus_BrushCreateSolid ()
Local Const $length = 250
Local Const $Pi = ACos(-1)
Local Const $amout_of_dots = 6
Local $draw_coordinates[$amout_of_dots][4] = [ _; X y Z
 [-$length,     0,  0 ], _
 [$length, 0, 0 ], _
 [0,            -$length,   0 ], _
 [0,        $length,    0 ], _
 [0, 0,             -$length ], _
 [0, 0,             $length ]]

Local $x1, $y1, $x2, $y2
Local $b, $j, $x, $y, $z, $mx, $my, $mouse_pos
Local $zoom_counter = 100
Local Const $zoom_min = 50
Local Const $zoom_max = 125
Local Const $mouse_sense = 4000
Local Const $start_x = $Width / 2
Local Const $start_y = $Height / 2
Local Const $dx = @DesktopWidth / 2, $dy = @DesktopHeight / 2
Local Const $Red    = 0xFFF00000
Local Const $Green  = 0xFF00F000
Local Const $Blue   = 0xFF0000F0

MouseMove($dx, $dy, 1)

GUIRegisterMsg(0x020A, "WM_MOUSEWHEEL")

GUISetOnEvent(-3, "Close")

Do
 _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF)

 For $b = 0 To $amout_of_dots - 1 ;correct perspective
 $draw_coordinates[$b][3] = 1 + $draw_coordinates[$b][2] / 1500
 Next
 ;draw lines
 Draw_Lines(0, 1, $Red)         ;draw x axis - red
 Draw_Lines(2, 3, $Green)   ;draw y axis - green
 Draw_Lines(4, 5, $Blue)    ;draw z axis - blue

 $mouse_pos = MouseGetPos()
 For $j = 0 To $amout_of_dots - 1
        $My = (-$dy + $mouse_pos[1]) / $mouse_sense
        $Mx = (-$dx + $mouse_pos[0]) / $mouse_sense

        ToolTip("AngleX = " &$Mx &" AngleY = " &$My, $mouse_pos[0]+10, $mouse_pos[1]+10)
 Calc($My, $Mx, $j) ;calculate new coordinates
 Next

 _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $Width, $Height)
Until Not Sleep(30)

Func Draw_Lines($p1, $p2, $pColor)
    $x1 = $start_x
 $y1 = $start_y
    #cs
 $x1 = $start_x + $draw_coordinates[$p1][0] * $draw_coordinates[$p1][3]
 $y1 = $start_y + $draw_coordinates[$p1][1] * $draw_coordinates[$p1][3]
    #ce
 $x2 = $start_x + $draw_coordinates[$p2][0] * $draw_coordinates[$p2][3]
 $y2 = $start_y + $draw_coordinates[$p2][1] * $draw_coordinates[$p2][3]

 _GDIPlus_PenSetColor($hPen, $pColor)
 _GDIPlus_GraphicsDrawLine($hBackbuffer, $x1, $y1, $x2, $y2, $hPen)

;   _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $x2 - 15, $y2 - 15 , 30, 30, $hPen)
 _GDIPlus_BrushSetSolidColor($hBrush, $pColor)
    _GDIPlus_GraphicsFillEllipse($hBackbuffer,  $x2 - 15, $y2 - 15 , 30, 30, $hBrush)

Select
    Case $pColor = $Red
        $Str = "XAngle = "
        Case $pColor = $Green
        $Str = "YAngle = "
        Case $pColor = $Blue
        $Str = "ZAngle = "
EndSelect
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $Start_X - 10, $Start_Y - 10, 20, 20, 0) ; Origin
    _GDIPlus_GraphicsDrawString ($hBackbuffer, "Origin", $Start_X - 20, $Start_Y - 30)
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Str, $x2 - 20, $y2 - 30)

EndFunc ;==>Draw

Func Calc($angle_x, $angle_y, $i, $angle_z = 0)
 ;calculate 3D rotation
 $x = $draw_coordinates[$i][0] * Cos($angle_y) + $draw_coordinates[$i][2] * Sin($angle_y)
 $y = $draw_coordinates[$i][1]
 $z = -$draw_coordinates[$i][0] * Sin($angle_y) + $draw_coordinates[$i][2] * Cos($angle_y)

 $draw_coordinates[$i][0] = $x
 $draw_coordinates[$i][1] = $y * Cos($angle_x) - $z * Sin($angle_x)
 $draw_coordinates[$i][2] = $y * Sin($angle_x) + $z * Cos($angle_x)
EndFunc ;==>Calc

Func Close()
 _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
 _GDIPlus_BitmapDispose($hBitmap)
 _GDIPlus_GraphicsDispose($hBackbuffer)
 _GDIPlus_GraphicsDispose($hGraphics)
 _GDIPlus_Shutdown()
 Exit
EndFunc ;==>Close

Func Zoom($factor)
 Local $m
 For $m = 0 To $amout_of_dots - 1
 $draw_coordinates[$m][0] *= $factor
 $draw_coordinates[$m][1] *= $factor
 $draw_coordinates[$m][2] *= $factor
 Next
EndFunc

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
 Local $wheel_Dir = BitAND($wParam, 0x800000)
 If $wheel_Dir > 0 Then
 If $zoom_counter <= $zoom_max Then
 Zoom(1.05)
 $zoom_counter += 1
 EndIf
 Else
 If $zoom_counter >= $zoom_min Then
 Zoom(0.95)
 $zoom_counter -= 1
 EndIf
 EndIf
 Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_MOUSEWHEEL

Quick 2D example...

#include <GUIConstants.au3>
#include <GDIplus.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
$SliderGui = GUICreate("Move Slider to change Angle", 288, 63, 195, 335)
$Slider = GUICtrlCreateSlider(12, 18, 255, 23)
GUICtrlSetLimit($Slider, 360, 1)
GUISetState(@SW_SHOW)

Global Const $width     = 350
Global Const $height    = 300
Global $title = "GDI+ Double Buffer"

Global Const $nPI = 3.1415926535897932384626433832795

Global $iRadius = 120
Global $iCenter = 150
Global $iSize = 10
Global $iX1, $iY1, $iN ,$Rad,$iT,$R

Opt("GUIOnEventMode", 1)
$hwnd = GUICreate($title, $width, $height)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()

If @OSBuild < 7600 Then WinSetTrans($hwnd,"", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

Local $pColor = 0xFF0000F0
Local $hPen = _GDIPlus_PenCreate($pColor, 3)

_GDIPlus_GraphicsClear($hBackbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

While 1
 $Deg = GUICtrlRead($Slider)
;   For $Deg = 0 to 360 step 5
        _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF)
        $R = ($nPI / 2) - ($Deg * ($nPI /180))
        $iX1 = $iCenter + Cos($R) * $iRadius
        $iY1 = $iCenter - Sin($R) * $iRadius
        _GDIPlus_GraphicsDrawLine($hBackbuffer, $iCenter, $iCenter, $iX1, $iY1, 0)
        _GDIPlus_GraphicsDrawString ($hBackbuffer, "Angle = " &$Deg, $iX1, $iY1)
 _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $width, $height)
    Sleep(100)
; next

WEnd

Func close()
 _GDIPlus_GraphicsDispose($hBackbuffer)
 _GDIPlus_BitmapDispose ($hBitmap)
 _GDIPlus_GraphicsDispose($hGraphics)
 _GDIPlus_Shutdown()
 Exit
EndFunc ;==>close

Thanks.

Is this what you looking for?

#include <GDIPlus.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 1)

Local Const $Width = 600
Local Const $Height = $Width
Local Const $W2 = $Width / 2
Local Const $H2 = $Height / 2
Local Const $deg = 180 / ACos(-1)
Local $hwnd = GUICreate("GDI+: 3D Axis by UEZ 2010 (use mouse wheel to zoom)", $Width, $Height)

GUISetState()

If @OSBuild < 7600 Then WinSetTrans($hwnd,"", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsClear($hBackbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

Local $Str
Local $pColor = 0xFF0000F0
Local $hPen = _GDIPlus_PenCreate($pColor, 3)
Local $hBrush = _GDIPlus_BrushCreateSolid ()
Local Const $length = 250
Local Const $Pi = ACos(-1)
Local Const $amout_of_dots = 6
Local $draw_coordinates[$amout_of_dots][4] = [ _; X     y   Z
    [-$length,  0,  0 ], _
    [$length,   0,  0 ], _
    [0,     -$length,   0 ], _
    [0,     $length,    0 ], _
    [0,     0,  -$length ], _
    [0,     0,  $length ]]

Local $x1, $y1, $x2, $y2
Local $b, $j, $x, $y, $z, $mx, $my, $mouse_pos
Local $zoom_counter = 100
Local Const $zoom_min = 50
Local Const $zoom_max = 125
Local Const $mouse_sense = 4000
Local Const $start_x = $Width / 2
Local Const $start_y = $Height / 2
Local Const $dx = @DesktopWidth / 2, $dy = @DesktopHeight / 2
Local Const $Red    = 0xFFF00000
Local Const $Green = 0xFF00F000
Local Const $Blue = 0xFF0000F0
Local $mwx, $mwy, $mwz, $angle, $rad = 180 / $Pi

MouseMove($dx, $dy, 1)

GUIRegisterMsg(0x020A, "WM_MOUSEWHEEL")

GUISetOnEvent(-3, "Close")

Do
    _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF)

    For $b = 0 To $amout_of_dots - 1 ;correct perspective
    $draw_coordinates[$b][3] = 1 + $draw_coordinates[$b][2] / 1500
    Next
    ;draw lines
    Draw_Lines(0, 1, $Red)  ;draw x axis - red
    Draw_Lines(2, 3, $Green)    ;draw y axis - green
    Draw_Lines(4, 5, $Blue)     ;draw z axis - blue

    $mouse_pos = MouseGetPos()

    For $j = 0 To $amout_of_dots - 1
    $My = (-$dy + $mouse_pos[1]) / $mouse_sense
    $Mx = (-$dx + $mouse_pos[0]) / $mouse_sense

;~  ToolTip("AngleX = " & $Mx &" AngleY = " &$My, $mouse_pos[0]+10, $mouse_pos[1]+10)
    Calc($My, $Mx, $j) ;calculate new coordinates
    Next

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $Width, $Height)
Until Not Sleep(30)

Func Draw_Lines($p1, $p2, $pColor)
    $x1 = $start_x
    $y1 = $start_y
    #cs
    $x1 = $start_x + $draw_coordinates[$p1][0] * $draw_coordinates[$p1][3]
    $y1 = $start_y + $draw_coordinates[$p1][1] * $draw_coordinates[$p1][3]
    #ce
    $x2 = $start_x + $draw_coordinates[$p2][0] * $draw_coordinates[$p2][3]
    $y2 = $start_y + $draw_coordinates[$p2][1] * $draw_coordinates[$p2][3]

    _GDIPlus_PenSetColor($hPen, $pColor)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x1, $y1, $x2, $y2, $hPen)

; _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $x2 - 15, $y2 - 15 , 30, 30, $hPen)
    _GDIPlus_BrushSetSolidColor($hBrush, $pColor)
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $x2 - 15, $y2 - 15 , 30, 30, $hBrush)


    $angle = Mod(360 - Abs(Angle($draw_coordinates[$p1][0], $draw_coordinates[$p2][1])), 360)
    Select
        Case $pColor = $Red
            $Str = "XAngle = " & StringFormat("%.2f", $angle)
        Case $pColor = $Green
            $Str = "YAngle = " & StringFormat("%.2f", $angle)
        Case $pColor = $Blue
            $Str = "ZAngle = " & StringFormat("%.2f", $angle)
    EndSelect
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $Start_X - 10, $Start_Y - 10, 20, 20, 0) ; Origin
    _GDIPlus_GraphicsDrawString ($hBackbuffer, "Origin", $Start_X - 20, $Start_Y - 30)
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Str, $x2 - 20, $y2 - 30)

EndFunc ;==>Draw

Func Angle($x, $y)
    Local $angle
    If $x = 0 Then
        $angle = 0
    Else
        $angle = -ATan($y / -$x) * $deg
    EndIf
    If -$x < 0 Then
        $angle = -180 + $angle
    ElseIf -$x >= 0 And $y < 0 Then
        $angle = -360 + $angle
    EndIf
    Return $angle
EndFunc

Func Calc($angle_x, $angle_y, $i, $angle_z = 0)
    ;calculate 3D rotation
    $x = $draw_coordinates[$i][0] * Cos($angle_y) + $draw_coordinates[$i][2] * Sin($angle_y)
    $y = $draw_coordinates[$i][1]
    $z = -$draw_coordinates[$i][0] * Sin($angle_y) + $draw_coordinates[$i][2] * Cos($angle_y)

    $draw_coordinates[$i][0] = $x
    $draw_coordinates[$i][1] = $y * Cos($angle_x) - $z * Sin($angle_x)
    $draw_coordinates[$i][2] = $y * Sin($angle_x) + $z * Cos($angle_x)
EndFunc ;==>Calc

Func Close()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc ;==>Close

Func Zoom($factor)
    Local $m
    For $m = 0 To $amout_of_dots - 1
    $draw_coordinates[$m][0] *= $factor
    $draw_coordinates[$m][1] *= $factor
    $draw_coordinates[$m][2] *= $factor
    Next
EndFunc

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    Local $wheel_Dir = BitAND($wParam, 0x800000)
    If $wheel_Dir > 0 Then
    If $zoom_counter <= $zoom_max Then
    Zoom(1.05)
    $zoom_counter += 1
    EndIf
    Else
    If $zoom_counter >= $zoom_min Then
    Zoom(0.95)
    $zoom_counter -= 1
    EndIf
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_MOUSEWHEEL

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Really good, thanks Uez. ;)

Your are welcome!

Btw, I added some more examples. If you are interested have a look to my 1st post!

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I was inspired by watching this Amiga Demo to try and do something similar with GDI+.

This is the result.

The Zip file has the external files used.

#include <GUIConstants.au3>
#include <GDIplus.au3>
#Include <Misc.au3>

Global $title = "GDI+"
Global Const $nPI       = 3.1415926535897932384626433832795
Global Const $PiDiv     = $nPI /180

Global $Music = "\Audio.xm"
Global $iRadius   = 200
Global $iCenter   = 600/2 -17
Global $iSize     = 10
Global $iX1, $iY1, $iN ,$Rad,$iT,$R
Global $Ball_1, $Ball1_x1, $Ball1_y1, $Ball1_Width, $Ball1_Height, $i
Global $Ball_2, $Ball1_x2, $Ball1_y2, $Ball2_Width, $Ball2_Height, $Radius = $iRadius
Global $Ball_3, $Ball3_x1, $Ball3_y1, $Ball3_Width, $Ball3_Height

    Global $graphics, $bitmap, $backbuffer, $hGUI,$hBrush, $Gray1 = 0xE0EEEEEE, $Gray2 = 0xD0DDDDDD
    Global $iX = 0, $iY = 0, $Width = 600, $Height = 600, $Col, $hPen, $iWidth = 100, $iHeight =100, $end = 0
    Global $hBrush, $hFormat, $hFamily, $hFont, $text_color, $text_scroller, $tLayout, $pen, $brush
    Global $htextBrush1, $hFormat1, $hFamily1, $hFont1, $text_color1, $tLayout1, $text1
    Global $hShadowBrush, $hShadowFormat, $hShadowFamily, $hShadowFont, $Shadow_color, $tShadow, $Shadowtext ,$ShadowtLayout
    Global $hShadowBrush1, $hShadowFormat1, $hShadowFamily1, $hShadowFont1, $Shadow_color1, $tShadow1, $Shadowtext1,$ShadowtLayout1
    Global $letter_distance, $Letter_Distance1 ,$x, $y, $Length, $scroller_length, $Scroller_Length1 ,$k1, $bassdll
    Global $pColor = 0xFF0000F0, $White = 0xF0FFFFFF, $ShadowColor = 0xFFABA9BA
    Global $font_size = 64, $Fontoffset = 5, $iRadius1, $Ex, $Ey, $eRadius, $hPen1, $hPen2, $ioffset, $i2, $y1, $x1, $i1, $Tog = 0
$text = "Greetings Fellow Autoit users....    Yes, Another GDI+ Example.....       A CrossHatch and Text Srcoller with Spinning Balls! :-)      ....Thanks to Autoit and the wonderfull Forum!"
$text1 = "Press F1 - F6 to see the Demos"
; Build your GUI here
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate($title, $width, $height)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()

$dll = DllOpen("user32.dll") ;For _Ispressed

If @OSBuild < 7600 Then WinSetTrans($hGUI,"", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

; Load your GDI+ resources here:
_GDIPlus_Startup()

;                       load Ball image
Local $Ball_1 = _GDIPlus_ImageLoadFromFile (@ScriptDir & "\YellBall.png")
Local $Ball1_Width = _GDIPlus_ImageGetWidth($Ball_1)
Local $Ball1_Height = _GDIPlus_ImageGetHeight($Ball_1)

Local $Ball_2 = _GDIPlus_ImageLoadFromFile (@ScriptDir & "\PurpleBall.png")


;Setup Scroll Font
$text_color = 0xFF6209D6
$htextBrush = _GDIPlus_BrushCreateSolid($text_color)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, $font_size, 2)
$pen = _GDIPlus_PenCreate(0)
$brush = _GDIPlus_BrushCreateSolid(0)
$tLayout = _GDIPlus_RectFCreate(0, 0)
;Setup Shadow Scroll Font
$Fontoffset = 5

$hShadowBrush = _GDIPlus_BrushCreateSolid($ShadowColor)
$hShadowFormat = _GDIPlus_StringFormatCreate()
$hShadowFamily = _GDIPlus_FontFamilyCreate("Arial")
$hShadowFont = _GDIPlus_FontCreate($hShadowFamily, $font_size, 2)
$tShadowtLayout = _GDIPlus_RectFCreate(0, 0)

;Setup Function Scroll Font
$font_size1 = 32
$text_color1 = 0xFF6209D6
$htextBrush1 = _GDIPlus_BrushCreateSolid($text_color)
$hFormat1 = _GDIPlus_StringFormatCreate()
$hFamily1 = _GDIPlus_FontFamilyCreate("Arial")
$hFont1 = _GDIPlus_FontCreate($hFamily, $font_size1, 2)
$pen1 = _GDIPlus_PenCreate(0)
$brush1 = _GDIPlus_BrushCreateSolid(0)
$tLayout1 = _GDIPlus_RectFCreate(0, 0)
;Setup Function Shadow Scroll Font
$Fontoffset1 = 5
$hShadowBrush1 = _GDIPlus_BrushCreateSolid($ShadowColor)
$hShadowFormat1 = _GDIPlus_StringFormatCreate()
$hShadowFamily1 = _GDIPlus_FontFamilyCreate("Arial")
$hShadowFont1 = _GDIPlus_FontCreate($hShadowFamily, $font_size1, 2)
$tShadowtLayout1 = _GDIPlus_RectFCreate(0, 0)

_GDIPlus_GraphicsSetSmoothingMode($BackBuffer, 2)
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
$backbuffer  =  _GDIPlus_ImageGetGraphicsContext($bitmap)


$hBrush = _GDIPlus_BrushCreateSolid ()

 Intro()        ; Intro Sequence

If FileExists(@ScriptDir & "\Bassmod.dll") And FileExists(@ScriptDir & $Music) Then
    Play_Audio()
    $found = True
Else
    $found = False
EndIf

;Main text Ini
    $letter_distance = $font_size
    $Length  = $font_size * 1.666 * 0.36
    $Length1 = $font_size1 * 1.666 * 0.36
    $k = $width

    $letter_distance1 = $font_size1
    $scroller_length  = StringLen($text) * $Length
    $scroller_length1 = StringLen($text1) * $Length1
    $k1 = $k

    $FontY = $height - $font_size * 1.5
    $FontY1 = 100 - $font_size * 1.5


Do                  ;main loop

For $iOffset = -200 to 0 step 5
        _GDIPlus_GraphicsClear($Backbuffer, 0x00)   ;Clear BackBuffer
    $Col = $Gray1
    $iY = $iY + $iOffset                            ;Scroll CrossHatch
    For $n = 0 to 48
        _GDIPlus_BrushSetSolidColor($hBrush, $Col)
        _GDIPlus_GraphicsFillRect($BackBuffer,   $iX, $iY, $iWidth, $iHeight, $hBrush)
;       _GDIPlus_GraphicsDrawRect ($BackBuffer, $iX, $iY, $Width,$Height)
        ColorSwitch()
        $iX += 100
        If $iX = 600 then
            ColorSwitch()
            $iX = 0
            $iY += 100
        EndIf
    next
    $iY = 0
    $iX = 0
Select
    Case _IsPressed("70", $dll)
        $Tog = 1
    Case _IsPressed("71", $dll)
        $Tog = 2
    Case _IsPressed("72", $dll)
        $Tog = 3
    Case _IsPressed("73", $dll)
        $Tog = 4
    Case _IsPressed("74", $dll)
        $Tog = 5
    Case _IsPressed("75", $dll)
        $Tog = 6
EndSelect

Select
    Case $Tog = 0
        ScrollText1()
        Demo1()
    Case $Tog = 1
        Demo1()
    Case $Tog = 2
        Demo2()
    Case $Tog = 3
        Demo3()
    Case $Tog = 4
        Demo4()
    Case $Tog = 5
        Demo5()
    Case $Tog = 6
        Demo6()
EndSelect

ScrollText()
        sleep(10)
            _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) ; Copy Buffer to GUI
next
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Func Intro()
            ;Setup  Intro Font
$font_size0 = 128
$text_color0  = 0xFF000000
$htextBrush0 = _GDIPlus_BrushCreateSolid($text_color0)
$hPen  = _GDIPlus_PenCreate ($ShadowColor,10)
$hPen1  = _GDIPlus_PenCreate ($ShadowColor,20)
$hPen2 = _GDIPlus_PenCreate ($ShadowColor,5)

$hFormat0 = _GDIPlus_StringFormatCreate()
$hFamily0 = _GDIPlus_FontFamilyCreate("Arial")
$hFont0   = _GDIPlus_FontCreate($hFamily0, $font_size0, 2)
$tLayout0 = _GDIPlus_RectFCreate(0, 0)

            ;Setup ShadowFont
;$Fontoffset = 5
$Shadowfont_size0 = 128
$hShadowBrush0 = _GDIPlus_BrushCreateSolid($ShadowColor)
$hShadowFormat0 = _GDIPlus_StringFormatCreate()
$hShadowFamily0 = _GDIPlus_FontFamilyCreate("Arial")
$hShadowFont0   = _GDIPlus_FontCreate($hShadowFamily0, $font_size0, 2)
$ShadowtLayout0 = _GDIPlus_RectFCreate(0, 0)

$FontX0 = -($font_size0 * 0.2) + ($Width/2 - $font_size0 * 0.5)
$FontY0 = -($font_size0 * 0.2) + ($height/2 - $font_size0 * 0.5)

    $G0 = "GO!"
    DllStructSetData($tLayout0, "x", $FontX0)
    DllStructSetData($tLayout0, "y", $FontY0)
    DllStructSetData($ShadowtLayout0, "x", $FontX0 + $Fontoffset)
    DllStructSetData($ShadowtLayout0, "y", $FontY0 + $Fontoffset)

$GoPos =  $FontX0 - $Font_Size0 + 20
    $ioffset    = 271
    $WidthDiv   = $Width / 2
    $Length     = 200

For $text0 = 3 to 0 step -1                                 ;Countdown
    For $i = 0 + $ioffset  to 360 + $ioffset step 20
        _GDIPlus_GraphicsClear($BackBuffer, 0x50FFFFFF)                             ;Clear BackBuffer
        $iX = 0
        $iY = 0
;Draw CheckerBoard
        ColorSwitch()
        For $n = 0 to 48
            _GDIPlus_BrushSetSolidColor($hBrush, $Col)
            _GDIPlus_GraphicsFillRect($BackBuffer,   $iX, $iY, $iWidth, $iHeight, $hBrush)
    ;       _GDIPlus_GraphicsDrawRect ($BackBuffer, $iX, $iY, $Width,$Height)
            ColorSwitch()
            $iX += 100
            If $iX = 600 then
                ColorSwitch()
                $iX = 0
                $iY += 100
            EndIf
;Draw Circles
            $eRadius     = 500
            $Ex = $Width/ 12
            $Ey = $Ex
            _GDIPlus_GraphicsDrawEllipse ($Backbuffer, $Ex, $Ey, $eRadius, $eRadius, $hPen)
            $eRadius = 400
            $Ex = $Width/ 6
            $Ey = $Ex
            _GDIPlus_GraphicsDrawEllipse ($Backbuffer, $Ex, $Ey, $eRadius, $eRadius, $hPen1)
            $eRadius = 300
            $Ex = $Width/ 4
            $Ey = $Ex
            _GDIPlus_GraphicsDrawEllipse ($Backbuffer, $Ex, $Ey, $eRadius, $eRadius, 0)
;Draw target lines
            _GDIPlus_GraphicsDrawLine($Backbuffer, $Width - $Length, $WidthDiv, $Width, $WidthDiv, $hPen2) ;middle right
            _GDIPlus_GraphicsDrawLine($Backbuffer, 0, $WidthDiv, $Length, $WidthDiv, $hPen2)            ; middle left
            _GDIPlus_GraphicsDrawLine($Backbuffer, $WidthDiv, 0, $WidthDiv, $Length, $hPen2)            ; middle top
            _GDIPlus_GraphicsDrawLine($Backbuffer, $WidthDiv, 400, $WidthDiv, $Width, $hPen2)           ; middle bottom
;draw rotating line
            $Center = $Height/2
            $R = ($PiDiv) - ($i * ($PiDiv))
            $iX1 = $Center + Cos($R) * $eRadius /2
            $iY1 = $Center - Sin($R) * $eRadius /2
            _GDIPlus_GraphicsDrawLine($Backbuffer, $Center, $Center, $iX1, $iY1, $hPen2)
        next
        Sleep(10)
;CountDown Text
        Select
            Case $text0 = 0
            $hPen2 = 0
            $text0 = $G0
            $FontX0 = $GoPos
            DllStructSetData($tLayout0, "x", $FontX0)
            DllStructSetData($ShadowtLayout0, "x", $FontX0 - $Fontoffset)
        EndSelect
        ;Paint Text
            _GDIPlus_GraphicsDrawStringEx($BackBuffer, $text0, $hShadowFont0, $ShadowtLayout0, $hShadowFormat0, $hShadowBrush0)
            _GDIPlus_GraphicsDrawStringEx($BackBuffer, $text0, $hFont0, $tLayout0, $hFormat0, $htextBrush0)

            _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) ; Copy Buffer to GUI
    next
Next

    _GDIPlus_BrushDispose($hShadowbrush0)
    _GDIPlus_FontDispose ($hShadowFont0)
    _GDIPlus_FontFamilyDispose ($hShadowFamily0)
    _GDIPlus_StringFormatDispose ($hShadowFormat0)

    _GDIPlus_BrushDispose($htextBrush0)
    _GDIPlus_FontDispose ($hFont0)
    _GDIPlus_FontFamilyDispose ($hFamily0)
    _GDIPlus_StringFormatDispose ($hFormat0)
EndFunc

Func Demo1()
    $i += 2
        $R1 = ($nPI / 2) - ($i  * $PiDiv)
        $CosRadius = Cos($R1) * $Radius
   For $Deg = 0 + $i to 360 + $i step 20
        $R = $PiDiv - ($Deg  * $PiDiv)
        $Ball1_x1 = $iCenter + Cos($R) * $CosRadius
        $Ball1_y1 = $iCenter - Sin($R) * $CosRadius

        $R1 = ($nPI / 2) - ($i  * $PiDiv)
        $SinRadius = Sin($R1) * $Radius
        $R = $PiDiv - ($Deg   * $PiDiv)
        $Ball2_y1 = $iCenter + Cos($R) * $SinRadius
        $Ball2_x1 = $iCenter - Sin($R) * $SinRadius

        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_1, $Ball1_x1, $Ball1_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_2, $Ball2_x1, $Ball2_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
    next
    If $i = 360 then $i = 0
EndFunc

Func Demo2()
    $i += 2
    $inc = 14.1 ;14.1
        $R1 = ($nPI / 2) - ($i  * $PiDiv)
        $CosRadius = Cos($R1) * $Radius
        $Start = 40
        $End  = 600 - 40
   For $Deg = $i  to 360  + $i  step 10
        $R = $PiDiv - ($Deg  * $PiDiv)
        $Ball1_x1 = $x1
        $Ball2_x1 = $x1
        $Ball1_y1 = $iCenter + Sin($R) * $Radius
        $Ball2_y1 = $iCenter + Cos($R) * $Radius

        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_1, $Ball1_x1, $Ball1_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_2, $Ball2_x1, $Ball2_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
    $x1 += $inc
    If $x1 > $End then $x1 = $Start
    next
    If $i = 360  then $i = 0
EndFunc

Func Demo3()
        $i += 2
        $R1 = ($nPI / 2) - ($i  * $PiDiv)
   For $Deg = 0 + $i to 360 + $i step 20
        $R = $PiDiv - ($Deg  * $PiDiv)
        $Ball1_x1 = $iCenter + Cos($R) * ($Radius + 5 )
        $Ball1_y1 = $iCenter - Sin($R) * ($Radius + 5 )

        $Ball2_y1 = $iCenter + Cos($R) * ($Radius - 30 )
        $Ball2_x1 = $iCenter - Sin($R) * ($Radius - 30 )

        $Ball3_x1 = $iCenter + Cos($R) * ($Radius - 65 )
        $Ball3_y1 = $iCenter - Sin($R) * ($Radius - 65 )

        $Ball4_y1 = $iCenter + Cos($R) * ($Radius - 95 )
        $Ball4_x1 = $iCenter - Sin($R) * ($Radius - 95 )

        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_1, $Ball1_x1, $Ball1_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_2, $Ball2_x1, $Ball2_y1, $Ball1_Width, $Ball1_Height)
        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_1, $Ball3_x1, $Ball3_y1, $Ball1_Width, $Ball1_Height)
        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_2, $Ball4_x1, $Ball4_y1, $Ball1_Width, $Ball1_Height)
    next
    If $i = 360 then $i = 0
EndFunc

Func Demo4()
    $i += 2
        $R1 = ($nPI / 2) - ($i  * $PiDiv)
        $CosRadius = Cos($R1) * $Radius
   For $Deg = 0 + $i to 360 + $i step 10
        $R = $PiDiv - ($Deg  * $PiDiv)
        $Ball1_x1 = $iCenter + Cos($R) * $CosRadius  * Cos($i * $PiDiv)
        $Ball1_y1 = $iCenter - Sin($R * 2) * $CosRadius

        $Ball2_x1 = $iCenter + Cos($R) * $CosRadius
        $Ball2_y1 = $iCenter - Sin($R * 2) * $CosRadius  * Cos($i * $PiDiv)

        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_1, $Ball1_x1, $Ball1_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_2, $Ball2_x1, $Ball2_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
    next
    If $i = 360 then $i = 0
EndFunc

Func Demo5()
        $i1 += 5
   For $Deg = 0 + $i to 360 + $i step 30
        $R = $PiDiv - ($Deg  * $PiDiv)
        $R1 = $PiDiv - ($i1  * $PiDiv)
        $CenterX = $iCenter - Cos($R1) * ($Radius/2)
        $CenterY = $iCenter + Sin($R1) * ($Radius/2)

            $Ball1_x1 = $CenterX - Sin($R) * ($Radius/1.5)
            $Ball1_y1 = $CenterY + Cos($R) * ($Radius/1.5)
            _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_1, $Ball1_x1, $Ball1_y1, $Ball1_Width, $Ball1_Height)

            $Ball2_x1 = $CenterY + Cos($R) * ($Radius/1.5)
            $Ball2_y1 = $CenterX - Sin($R) * ($Radius/1.5)
            _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_2, $Ball2_x1, $Ball2_y1, $Ball1_Width, $Ball1_Height)
$i += 5
next
EndFunc

Func Demo6()
    $i += 2
        $R1 = ($nPI / 2) - ($i  * $PiDiv)
        $CosRadius = Cos($R1) * $Radius
   For $Deg = 0 + $i to 360 + $i step 20
        $R = $PiDiv - ($Deg  * $PiDiv)
        $Ball1_x1 = $iCenter + Cos($R) * $CosRadius  * Cos($i * $PiDiv)
        $Ball1_y1 = $iCenter - Sin($R) * $CosRadius

        $Ball2_x1 = $iCenter + Cos($R) * $CosRadius
       $Ball2_y1 = $iCenter - Sin($R) * $CosRadius   * Sin($i * $PiDiv)

        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_1, $Ball1_x1, $Ball1_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
        _GDIPlus_GraphicsDrawImageRect($BackBuffer, $Ball_2, $Ball2_x1, $Ball2_y1, $Ball1_Width, $Ball1_Height) ; Draw image to BackBuffer
    next
    If $i = 360 then $i = 0
EndFunc

Func ScrollText()
    $FontX = $k + $letter_distance
    DllStructSetData($tLayout, "x", $FontX)
    DllStructSetData($tLayout, "y", $FontY)

    DllStructSetData($tShadowtLayout, "x", $FontX + $Fontoffset)
    DllStructSetData($tShadowtLayout, "y", $FontY + $Fontoffset)

    _GDIPlus_GraphicsDrawStringEx($BackBuffer, $text, $hShadowFont, $tShadowtLayout, $hShadowFormat, $hShadowBrush)
    _GDIPlus_GraphicsDrawStringEx($BackBuffer, $text, $hFont, $tLayout, $hFormat, $htextBrush)
    $k -= 4
    If -$scroller_length >= $k + $width Then $k = $width
EndFunc

Func ScrollText1()
    $FontX1 = $k1 + $letter_distance1
    DllStructSetData($tLayout1, "x", $FontX1)
    DllStructSetData($tLayout1, "y", $FontY1)

    DllStructSetData($tShadowtLayout1, "x", $FontX1 + $Fontoffset)
    DllStructSetData($tShadowtLayout1, "y", $FontY1 + $Fontoffset)

    _GDIPlus_GraphicsDrawStringEx($BackBuffer, $text1, $hShadowFont1, $tShadowtLayout1, $hShadowFormat1, $hShadowBrush1)
    _GDIPlus_GraphicsDrawStringEx($BackBuffer, $text1, $hFont1, $tLayout1, $hFormat1, $htextBrush1)
    $k1 -= 4
    If -$scroller_length1 >= $k1 + $width Then $k1 = $width
EndFunc

Func ColorSwitch()
            if $Col = $Gray1 Then
                $Col = $Gray2
                    Else
                $Col = $Gray1
            EndIf
        EndFunc

Func Play_Audio()
    $bassdll = DllOpen(@ScriptDir & "\BASSMOD.dll")
    $Init = DllCall($bassdll, "int", "BASSMOD_Init", "int", -1, "int", 44100, "int", 0)
    $string= DllStructCreate("char[255]")
    DllStructSetData($string, 1, @ScriptDir & $Music)
    $load = DllCall($bassdll, "int", "BASSMOD_MusicLoad", _
                             "int", 0, _
                             "ptr", DllStructGetPtr($string), _
                             "int", 0, _
                             "int", 0, _
                             "int", 4 + 1024)
    $VolLevel = 100
    $Volume = DllCall($BASSDLL, "int", "BASSMOD_SetVolume", "int", $VolLevel)
    DllCall($bassdll, "int", "BASSMOD_MusicPlay")
EndFunc

Func close()
    _GDIPlus_BrushDispose($htextbrush)
    _GDIPlus_FontDispose ($hFont)
    _GDIPlus_FontFamilyDispose ($hFamily)
    _GDIPlus_StringFormatDispose ($hFormat)

    _GDIPlus_BrushDispose($htextbrush1)
    _GDIPlus_FontDispose ($hFont1)
    _GDIPlus_FontFamilyDispose ($hFamily1)
    _GDIPlus_StringFormatDispose ($hFormat1)

    _GDIPlus_BrushDispose($hShadowbrush)
    _GDIPlus_FontDispose ($hShadowFont)
    _GDIPlus_FontFamilyDispose ($hShadowFamily)
    _GDIPlus_StringFormatDispose ($hShadowFormat)

    _GDIPlus_BrushDispose($hShadowbrush1)
    _GDIPlus_FontDispose ($hShadowFont1)
    _GDIPlus_FontFamilyDispose ($hShadowFamily1)
    _GDIPlus_StringFormatDispose ($hShadowFormat1)

    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose ($Graphics)
    _GDIPlus_Shutdown ()
    DllCall($bassdll, "int", "BASSMOD_MusicStop(")
    DllCall($bassdll, "int", "BASSMOD_Free")
    DllClose($bassdll)
    DllClose($dll)
    Exit
EndFunc ;==>close

Scroller Sine Blobs.zip

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

Very good Lakes ;)

I like it!

Yeah, the good old C64/Amiga days...:)

Thanks for sharing!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I`ve put the Cube and 3D axis code together with some extra bits...

#include <GDIPlus.au3>
#include <Misc.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 1)

Global $user32_dll = DllOpen("user32.dll")
Global $Reset, $hPenDotted, $hPenDash, $ResetCube, $CubeX, $CubeY, $CubeZ
Global $CubeX1, $CubeY1, $CubeX2, $CubeY2, $CubeX3, $CubeY3, $CubeX4, $CubeY4
Global $Tog, $Tog1, $Tog2, $Tog3, $Tog4 = True, $Tog5, $Tog6, $Tog7 = True, $T, $Delay = 100
Global $Text  = "Press F1 to F6 to Toogle Cube Faces (F7 Toggles the Autoit Logo being Painted)"
Global $text1 = "Left Mouse Button to Rotate, Right Mouse Button to Reset (Mouse wheel to Zoom)"

Local $dot_distance = 150
Local Const $Width = 600
Local Const $Height = $Width
Local Const $W2 = $Width / 2
Local Const $H2 = $Height / 2
Local Const $deg = 180 / ACos(-1)
Local $hwnd = GUICreate("Orginal Code by UEZ ", $Width, $Height)

GUISetState()

If @OSBuild < 7600 Then WinSetTrans($hwnd,"", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsClear($hBackbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

Local $hImage = _GDIPlus_ImageLoadFromFile ("C:\Program Files\AutoIt3\Examples\GUI\logo4.gif")

Local $Str
Local $pColor = 0xFF0000F0
Local $hPen = _GDIPlus_PenCreate($pColor, 8)
        _GDIPlus_PenSetEndCap($hPen, $GDIP_LINECAPARROWANCHOR)
Local $hCubePen = _GDIPlus_PenCreate(0x400000F0, 8)
        _GDIPlus_PenSetEndCap($hCubePen, $GDIP_LINECAPARROWANCHOR)
Local $hBrush = _GDIPlus_BrushCreateSolid ()
Local $hBrush1 = _GDIPlus_BrushCreateSolid(0x60FFFF00)
Local $hBrush2 = _GDIPlus_BrushCreateSolid(0x60FF8000)
$hPenDash = _GDIPlus_PenCreate (0xFF000000, 2)
    _GDIPlus_PenSetDashStyle ($hPenDash, $GDIP_DASHSTYLEDASH)
$hPenDotted = _GDIPlus_PenCreate (0xFF000000, 2)
    _GDIPlus_PenSetDashStyle ($hPenDotted, $GDIP_DASHSTYLEDOT)
Local Const $length = 250
Local Const $Pi = ACos(-1)
Local Const $amout_of_dots = 6
Local Const $amout_of_cube_dots = 9

#cs
        X           Y           Z
---------------------------------------
1    [-$length,     0,          0 ], _
2    [ $length,     0,          0 ], _
3    [  0,      -$length,       0 ], _
4    [  0,       $length,       0 ], _
5    [  0,          0,      -$length ], _
6    [  0,          0,       $length ]]
#ce

; Axis Coords
Local $draw_coordinates[$amout_of_dots][4] = [ _;   X                   y                   Z
                                                [-$length,              0,                  0   ], _
                                                [$length,               0,                  0   ], _
                                                [0,                     -$length,           0   ], _
                                                [0,                     $length,            0   ], _
                                                [0,                     0,                  -$length   ], _
                                                [0,                     0,                  $length    ]]
$Reset = $draw_coordinates

Local $cube_coordinates[$amout_of_cube_dots][4] = [ _;  X                   y                   Z
                                                [-$dot_distance,    -$dot_distance,     -$dot_distance  ], _
                                                [$dot_distance,     -$dot_distance,     -$dot_distance  ], _
                                                [$dot_distance,     $dot_distance,      -$dot_distance  ], _
                                                [-$dot_distance,    $dot_distance,      -$dot_distance  ], _
                                                [-$dot_distance,    -$dot_distance,     $dot_distance   ], _
                                                [$dot_distance,     -$dot_distance,     $dot_distance   ], _
                                                [$dot_distance,     $dot_distance,      $dot_distance   ], _
                                                [-$dot_distance,    $dot_distance,      $dot_distance   ]]
$ResetCube = $cube_coordinates


Local $x1, $y1, $x2, $y2
Local $b, $j, $x, $y, $z, $mx, $my, $MPos
Local $zoom_counter = 100
Local Const $zoom_min = 50
Local Const $zoom_max = 125
Local Const $mouse_sense = 4000
Local Const $start_x = $Width / 2
Local Const $start_y = $Height / 2
Local Const $dx = @DesktopWidth / 2, $dy = @DesktopHeight / 2
Local Const $Red    = 0xFFF00000
Local Const $Green = 0xFF00F000
Local Const $Blue = 0xFF0000F0
Local $mwx, $mwy, $mwz, $angle, $rad = 180 / $Pi

MouseMove($dx, $dy, 1)

GUIRegisterMsg(0x020A, "WM_MOUSEWHEEL")

GUISetOnEvent(-3, "Close")

Do
    _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF)

    For $b = 0 To $amout_of_dots - 1        ;correct axis perspective
        $draw_coordinates[$b][3] = 1 + $draw_coordinates[$b][2] / 1500
    Next
        For $c = 0 To $amout_of_cube_dots - 1 ;correct  cube perspective
        $cube_coordinates[$c][3] = 1 + $cube_coordinates[$c][2] / 0x600
    Next

    ;draw axis lines
    Draw_Lines(0, 1, $Red)                  ;draw x axis - red
    Draw_Lines(2, 3, $Green)                ;draw y axis - green
    Draw_Lines(4, 5, $Blue)                 ;draw z axis - blue
;--------------------------------------------------------------------

Select
    Case _IsPressed("70", $user32_dll)
        Sleep($Delay)
        $Tog1 = NOT $Tog1
;       Beep(100,50)

    Case _IsPressed("71",$user32_dll)
        Sleep($Delay)
        $Tog2 = NOT $Tog2
;       Beep(200,50)

    Case _IsPressed("72",$user32_dll)
        Sleep($Delay)
        $Tog3 = NOT $Tog3
;       Beep(300,50)

    Case _IsPressed("73", $user32_dll)
        Sleep($Delay)
        $Tog4 = NOT $Tog4
;       Beep(400,50)

    Case _IsPressed("74", $user32_dll)
        Sleep($Delay)
        $Tog5 = NOT $Tog5
;       Beep(500,50)

    Case _IsPressed("75", $user32_dll)
        Sleep($Delay)
        $Tog6 = NOT $Tog6
;       Beep(600,50)

    Case _IsPressed("76", $user32_dll)
        Sleep($Delay)
        $Tog7 = NOT $Tog7
;       Beep(700,50)
EndSelect

;       4 -- - - - 5
;     / |        / |
;    0 - -  - - 1  |
;    |  |       |  |
;    |  7 -- - -|- 6
;    | /        | /
;    3 - -  - - 2
    If $Tog1 = True then        Draw_Cube_Lines(3, 2, 6, 7)     ;F1 bottom
    If $Tog2 = True then        Draw_Cube_Lines(5, 1, 0, 4)     ;F2 top
    If $Tog3 = True then        Draw_Cube_Lines(1, 2, 3, 0)     ;F3 front
    If $Tog4 = True then        Draw_Cube_Lines(7, 6, 5 ,4)     ;F4 rear
    If $Tog5 = True then        Draw_Cube_Lines(6, 2, 1, 5)     ;F5 right
    If $Tog6 = True then        Draw_Cube_Lines(0, 3, 7, 4)     ;F6 left

    If _IsPressed("01", $user32_dll) Then   ; Left mouse button to Rotate
        $MPos = MouseGetPos()
        For $j = 0 To $amout_of_dots - 1
            $Mx = ($dx - $MPos[0]) / $mouse_sense
            $My = -($dy - $Mpos[1]) / $mouse_sense
            Calc($My, $Mx, $j)              ;calculate axis coordinates
        Next
        For $j = 0 To $amout_of_Cube_dots - 1
            CubeCalc($My, $Mx, $j)          ;calculate cube coordinates
        Next
    EndIF
    If _IsPressed("02", $user32_dll) Then   ;Right mouse button to Reset CoOrds and Toggles to inital values
       $draw_coordinates = $Reset
       $cube_coordinates = $ResetCube
       $Tog1 = False
       $Tog2 = False
       $Tog3 = False
       $Tog4 = True     ;Draw this Face as Default
       $Tog5 = False
       $Tog6 = False
       $Tog7 = True     ;Paint Logo
    Endif

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $Width, $Height)
Until Not Sleep(30)

;Draw Axis Lines
Func Draw_Lines($p1, $p2, $pColor)
    $x1 = $start_x + $draw_coordinates[$p1][0] * $draw_coordinates[$p1][3]
    $y1 = $start_y + $draw_coordinates[$p1][1] * $draw_coordinates[$p1][3]

    $x2 = $start_x + $draw_coordinates[$p2][0] * $draw_coordinates[$p2][3]
    $y2 = $start_y + $draw_coordinates[$p2][1] * $draw_coordinates[$p2][3]

    _GDIPlus_PenSetColor($hPen, $pColor)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x1, $y1, $x2, $y2, $hPen)

    _GDIPlus_BrushSetSolidColor($hBrush, $pColor)
   _GDIPlus_GraphicsFillEllipse($hBackbuffer, $x1 - 10, $y1 - 10 , 20, 20, $hBrush)

    $angle = Mod(360 - Abs(Angle($draw_coordinates[$p1][0], $draw_coordinates[$p2][1])), 360)
    Select
        Case $pColor = $Red
            $Str = "XAngle = " & StringFormat("%.2f", $angle)
        Case $pColor = $Green
            $Str = "YAngle = " & StringFormat("%.2f", $angle)
        Case $pColor = $Blue
            $Str = "ZAngle = " & StringFormat("%.2f", $angle)
    EndSelect
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $Start_X - 10, $Start_Y - 10, 20, 20, 0) ; Origin
    _GDIPlus_GraphicsDrawString ($hBackbuffer, "Origin", $Start_X - 20, $Start_Y - 30)
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Str, $x2 - 20, $y2 - 30)
EndFunc ;==>Draw

Func Draw_Cube_Lines($Cp1, $Cp2, $Cp3, $Cp4)
    $CubeX1 = $start_x + $Cube_coordinates[$Cp1][0] * $Cube_coordinates[$Cp1][3]
    $CubeY1 = $start_y + $Cube_coordinates[$Cp1][1] * $Cube_coordinates[$Cp1][3]

    $CubeX2 = $start_x + $Cube_coordinates[$Cp2][0] * $Cube_coordinates[$Cp2][3]
    $CubeY2 = $start_y + $Cube_coordinates[$Cp2][1] * $Cube_coordinates[$Cp2][3]

    $CubeX3 = $start_x + $Cube_coordinates[$Cp3][0] * $Cube_coordinates[$Cp3][3]
    $CubeY3 = $start_y + $Cube_coordinates[$Cp3][1] * $Cube_coordinates[$Cp3][3]

    $CubeX4 = $start_x + $Cube_coordinates[$Cp4][0] * $Cube_coordinates[$Cp4][3]
    $CubeY4 = $start_y + $Cube_coordinates[$Cp4][1] * $Cube_coordinates[$Cp4][3]

;#######                    For Front Face              #########
;------------------------------- Top -------------------------------------------------------
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $CubeX4, $CubeY4, $CubeX1, $CubeY1, $hCubePen)                  ; top 0 - 1
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $CubeX4 - 5, $CubeY4 - 5 , 10, 10, 0)

    _GDIPlus_GraphicsDrawLine   ($hBackbuffer, $Start_X, $Start_Y, $CubeX4, $CubeY4,  $hPenDash)
   _GDIPlus_GraphicsDrawString ($hBackbuffer, $Cp4, $CubeX4- 10, $CubeY4 -20, "Arial", 12)
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Cp1, $CubeX1, $CubeY1 -20,  "Arial", 12)
;-------------------------------------------------------------------------------------------
;------------------------------- Right -------------------------------------------------------
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $CubeX1, $CubeY1, $CubeX2, $CubeY2, $hCubePen)                  ; right 2 - 1
;---------------------------------------------------------------------------------------------
;------------------------------- Bottom -------------------------------------------------------
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $CubeX2, $CubeY2, $CubeX3, $CubeY3, $hCubePen)                  ; bottom 3 - 2
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $CubeX2 - 5, $CubeY2 - 5 , 10, 10, 0)

    _GDIPlus_GraphicsDrawLine   ($hBackbuffer, $Start_X, $Start_Y, $CubeX2, $CubeY2,  $hPenDash)
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Cp2, $CubeX2 +5, $CubeY2, "Arial", 12)
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Cp3, $CubeX3 -10, $CubeY3,"Arial", 12)
;----------------------------------------------------------------------------------------------
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Text, 5, 550,"Arial", 12)                               ;Instructions
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Text1, 5, 570,"Arial", 12)

;------------------------------- Left --------------------------------------------------------
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $CubeX3, $CubeY3, $CubeX4, $CubeY4, $hCubePen)                  ; left
;----------------------------------------------------------------------------------------------
    _GDIPlus_GraphicsDrawString ($hBackbuffer, $Cp3, $CubeX3 -10, $CubeY3,"Arial", 12)
;--------------------------- Put the Autoit Logo image on one Face ----------------------------------------------
    if $Cp1 = 7 and $Tog7 = True then
    _GDIPlus_DrawImagePoints($hBackbuffer, $hImage, $start_x + $Cube_coordinates[$Cp4][0], $start_y + $Cube_coordinates[$Cp4][1], _
                                                    $start_x + $Cube_coordinates[$Cp3][0], $start_y + $Cube_coordinates[$Cp3][1], _
                                                    $start_x + $Cube_coordinates[$Cp1][0], $start_y + $Cube_coordinates[$Cp1][1])
    Endif
EndFunc   ;==>Draw

Func Angle($x, $y)
    Local $angle
    If $x = 0 Then
        $angle = 0
    Else
        $angle = -ATan($y / -$x) * $deg
    EndIf
    If -$x < 0 Then
        $angle = -180 + $angle
    ElseIf -$x >= 0 And $y < 0 Then
        $angle = -360 + $angle
    EndIf
    Return $angle
EndFunc

Func Calc($angle_x, $angle_y, $i, $angle_z = 0)
    ;calculate axis 3D rotation
    $x = $draw_coordinates[$i][0] * Cos($angle_y) + $draw_coordinates[$i][2] * Sin($angle_y)
    $y = $draw_coordinates[$i][1]
    $z = -$draw_coordinates[$i][0] * Sin($angle_y) + $draw_coordinates[$i][2] * Cos($angle_y)

    $draw_coordinates[$i][0] = $x
    $draw_coordinates[$i][1] = $y * Cos($angle_x) - $z * Sin($angle_x)
    $draw_coordinates[$i][2] = $y * Sin($angle_x) + $z * Cos($angle_x)
EndFunc ;==>Calc

Func CubeCalc($angle_x, $angle_y, $i)
    ;calculate Cube 3D rotation
    $CubeX = $Cube_coordinates[$i][0] * Cos($angle_y) + $Cube_coordinates[$i][2] * Sin($angle_y)
    $CubeY = $Cube_coordinates[$i][1]
    $CubeZ = -$Cube_coordinates[$i][0] * Sin($angle_y) + $Cube_coordinates[$i][2] * Cos($angle_y)

    $Cube_coordinates[$i][0] = $CubeX
    $Cube_coordinates[$i][1] = $CubeY * Cos($angle_x) - $CubeZ * Sin($angle_x)
    $Cube_coordinates[$i][2] = $CubeY * Sin($angle_x) + $CubeZ * Cos($angle_x)
EndFunc

Func Close()
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPenDash)
    _GDIPlus_PenDispose($hPenDotted)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    DllClose($User32_dll)
    Exit
EndFunc ;==>Close

Func Zoom($factor)
    Local $m
    For $m = 0 To $amout_of_dots - 1
        $draw_coordinates[$m][0] *= $factor
        $draw_coordinates[$m][1] *= $factor
        $draw_coordinates[$m][2] *= $factor
    Next
    For $m = 0 To $amout_of_Cube_dots - 1
        $Cube_coordinates[$m][0] *= $factor
        $Cube_coordinates[$m][1] *= $factor
        $Cube_coordinates[$m][2] *= $factor
    Next
EndFunc

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    Local $wheel_Dir = BitAND($wParam, 0x800000)
    If $wheel_Dir > 0 Then
    If $zoom_counter <= $zoom_max Then
    Zoom(1.05)
    $zoom_counter += 1
    EndIf
    Else
    If $zoom_counter >= $zoom_min Then
    Zoom(0.95)
    $zoom_counter -= 1
    EndIf
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_MOUSEWHEEL

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

@Lakes: thank you very much for your interest and your contributions to this topic (GDI+ stuff)! I assume most people are not really interested anymore or were never... but who cares? ;)

Your last examples shows really good what the problem is with _GDIPlus_DrawImagePoints()! I'm still trying to find a workaround.

I hope to see more examples...

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 1 month later...

Some more examples:

PHIreworks!

;Idea taken from http://js1k.com/demo/266
#include "GDIP.au3"
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

Global $iWidth = 800
Global $iHeight = 580

Global Const $PI = ATan(1) * 4
Global $PHI = (Sqrt(5) + 1) / 2

Global $iAmount = 120
Global $aDots[$iAmount + 1][2]
Global $iW2 = $iWidth / 2
Global $iH2 = $iHeight / 2

Global $hGui = GUICreate("PHIreworks!", $iWidth, $iHeight, Default, Default, BitOR($WS_POPUP, $WS_BORDER));, $WS_EX_TOPMOST)
GUISetOnEvent(-3, "_Exit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_ChangeType")
GUISetState()

_GDIPlus_Startup()
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)

Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

Global $hBrush = _GDIPlus_BrushCreateSolid(0xFF00FF00)
Global $hBrush_Trans = _GDIPlus_BrushCreateSolid(0x30000000)

Global $iType = 0
While 1
    Switch $iType
        Case 0
            _Draw(0, 0)
        Case 1
            _Draw(1, 2)
        Case 2
            _Draw(2, 0)
        Case Else
            _Draw(3, 1)
    EndSwitch
WEnd

Func _ChangeType()
    $iType += 1
    If $iType > 3 Then $iType = 0
EndFunc   ;==>_ChangeType


Func _Draw($iType_D = 0, $iType_S = 0)
    Local Static $iStep = 0, $iMax = 0
    If $iMax < $iAmount Then $iMax += 1
    $iStep += 1
    For $i = $iAmount To 1 Step -1
        $aDots[$i][0] = $aDots[$i - 1][0]
        $aDots[$i][1] = $aDots[$i - 1][1]
    Next

    $aDots[0][0] = $iStep * $PHI
    $aDots[0][1] = Mod(($iStep + ($iAmount / 3)), $iAmount) / $iAmount

    _GDIPlus_GraphicsFillRect($hGfxBuffer, 0, 0, $iWidth, $iHeight, $hBrush_Trans)

    Local $fColor
    For $i = 0 To $iMax
        $fColor = _HSLAtoARGB($aDots[$i][1], 1, 0.5, 1 - $i / $iAmount)
        _PlaceDot($aDots[$i][0], _Dist($i + 1, $iType_D), _Size($i, $iType_S), $fColor)
    Next

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_Draw


Func _HSLAtoARGB($nH, $nS, $nL, $nA)
    Local $nR, $nG, $nB
    Local $nValB = $nL * ($nS + 1)
    Local $nValA = 2 * $nL - $nValB

    $nR = _HueToRGB($nValA, $nValB, $nH + 1 / 3)
    $nG = _HueToRGB($nValA, $nValB, $nH)
    $nB = _HueToRGB($nValA, $nValB, $nH - 1 / 3)

    Return BitOR(BitShift($nA * 0xFF, -24), BitShift($nR * 0xFF, -16), BitShift($nG * 0xFF, -8), $nB * 0xFF)
EndFunc   ;==>_HSLAtoARGB


Func _HueToRGB($nA, $nB, $nH)
    If $nH < 0 Then $nH += 1
    If $nH > 1 Then $nH -= 1

    If (6 * $nH) < 1 Then Return $nA + ($nB - $nA) * 6 * $nH
    If (2 * $nH) < 1 Then Return $nB
    If (3 * $nH) < 2 Then Return $nA + ($nB - $nA) * 6 * (2 / 3 - $nH)
    Return $nA
EndFunc   ;==>_HueToRGB


Func _PlaceDot($angle, $distance, $size, $color)
    _GDIPlus_BrushSetSolidColor($hBrush, $color)
    Local $x = $iW2 + Cos($angle * 2 * $PI) * $distance
    Local $y = $iH2 + Sin($angle * 2 * $PI) * $distance
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hGfxBuffer, "handle", $hBrush, "float", $x - $size, "float", $y - $size, "float", $size * 2, "float", $size * 2)
EndFunc   ;==>_PlaceDot


Func _Dist($fX, $iType)
    Switch $iType
        Case 0
            Return $fX ^ 2 / 30 + 60
        Case 1
            Return Sqrt($fX) * 30
        Case 2
            Return $fX * 3
        Case Else
            Return ($iAmount - $fX) * 2
    EndSwitch
EndFunc   ;==>_Dist


Func _Size($fX, $iType)
    Switch $iType
        Case 0
            Return Log($fX + 2) * 3.5
        Case 1
            Return 22 - Log($fX + 2) * 3.5
        Case Else
            Return Log(Sin($fX / $iAmount * $PI) * 40 + 1) * 4 + 1
    EndSwitch
EndFunc   ;==>_Size


Func _Exit()
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BrushDispose($hBrush_Trans)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGui)
    Exit
EndFunc   ;==>_Exit

Galaxy

#include <GDIP.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global $iW = 800
Global $iH = 580

_GDIPlus_Startup()

Global $hPath = _GDIPlus_PathCreate()
_GDIPlus_PathAddRectangle($hPath, 0, 0, $iW, $iH)

Global $hGui = GUICreate("Galaxy", $iW, $iH)
GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT")
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
;_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)

Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 25)

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
GUISetState()

Global $fMax = 35
Global $fStep = -$fMax

While 1
    While $fStep < $fMax
        _Draw($fStep, $iW, $iH)
        $fStep += ($fMax - Abs($fStep) + 2) / 40
    WEnd

    While $fStep > -$fMax
        _Draw($fStep, $iW, $iH)
        $fStep -= ($fMax - Abs($fStep) + 2) / 40
    WEnd
WEnd

Func _Draw($fAngle, $iW, $iH, $iStep = 60, $fSX = 1.12, $fSY = 1.06)
    Local $iW2 = $iW / 2
    Local $iH2 = $iH / 2
    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 5, 5, 10, 10)

    Local $hMatrix_Scale = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix_Scale, $fSX, $fSY)
    Local $hMatrix_Rotate = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix_Rotate, $iW2, $iH2)
    _GDIPlus_MatrixRotate($hMatrix_Rotate, $fAngle)
    _GDIPlus_MatrixTranslate($hMatrix_Rotate, -$iW2, -$iH2)

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)
    Local $iCol
    For $i = 0 To $iStep
        TranslatePathCenter($hPath, $iW2, $iH2)
        _GDIPlus_PathTransform($hPath, $hMatrix_Rotate)
        $iCol = Round(($iStep - $i) * 0xFF / $iStep)
        _GDIPlus_PenSetColor($hPen, BitOR(BitShift($iCol, -24), BitShift($iCol, -16), BitShift(0, -8), 0))
        _GDIPlus_GraphicsDrawPath($hGfxBuffer, $hPath, $hPen)
        _GDIPlus_PathTransform($hPath, $hMatrix_Scale)
    Next

    _GDIPlus_MatrixDispose($hMatrix_Rotate)
    _GDIPlus_MatrixDispose($hMatrix_Scale)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_Draw

Func TranslatePathCenter(ByRef $hPath, $X, $Y)
    Local $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    Local $cX = $aBounds[0] + ($aBounds[2] / 2)
    Local $cY = $aBounds[1] + ($aBounds[3] / 2)
    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, $X - $cX, $Y - $cY)
    _GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)
EndFunc   ;==>TranslatePathCenter

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
EndFunc   ;==>WM_ERASEBKGND

Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Guilloche

;Idea taken from http://js1k.com/demo/195
#include "GDIP.au3"
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global $iWidth = 670
Global $iHeight = 580

Global Const $PI = ATan(1) * 4

Global $hGui = GUICreate("Guilloche", $iWidth + 130, $iHeight, Default, Default, BitOR($WS_POPUP, $WS_BORDER));, $WS_EX_TOPMOST)
GUISetOnEvent(-3, "_Exit")
Global $cSlider_1 = GUICtrlCreateSlider(10, 10, 25, 500, BitOR(0x0002, 0x0008, 0x0010))
GUICtrlSetLimit(-1, 500, 0)
GUICtrlSetData(-1, 497)
Global $cLabel_1 = GUICtrlCreateLabel(3, 5, 520, 25, 20, 0x01)
Global $cSlider_2 = GUICtrlCreateSlider(40, 10, 25, 500, BitOR(0x0002, 0x0008, 0x0010))
GUICtrlSetLimit(-1, 500, 0)
GUICtrlSetData(-1, 430)
Global $cLabel_2 = GUICtrlCreateLabel(70, 35, 520, 25, 20, 0x01)
Global $cSlider_3 = GUICtrlCreateSlider(70, 10, 25, 500, BitOR(0x0002, 0x0008, 0x0010))
GUICtrlSetLimit(-1, 500, 0)
GUICtrlSetData(-1, 500)
Global $cLabel_3 = GUICtrlCreateLabel(0, 65, 520, 25, 20, 0x01)
Global $cSlider_4 = GUICtrlCreateSlider(100, 10, 25, 500, BitOR(0x0002, 0x0008, 0x0010))
GUICtrlSetLimit(-1, 500, 0)
GUICtrlSetData(-1, 481)
Global $cLabel_4 = GUICtrlCreateLabel(19, 95, 520, 25, 20, 0x01)
GUICtrlCreateButton("Exit", 10, 550, 110, 20)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState()

_GDIPlus_Startup()
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)

Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

Global $hBmpTrans = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxTrans = _GDIPlus_ImageGetGraphicsContext($hBmpTrans)
_GDIPlus_GraphicsSetSmoothingMode($hGfxTrans, 2)
_GDIPlus_GraphicsSetInterpolationMode($hGfxTrans, 1)
Global $fTransform = 0.05
_GDIPlus_GraphicsResetTransform($hGfxTrans)
_GDIPlus_GraphicsTranslateTransform($hGfxTrans, -($iWidth / 2 * $fTransform), -($iHeight / 2 * $fTransform))
_GDIPlus_GraphicsScaleTransform($hGfxTrans, 1 + $fTransform, 1 + $fTransform)
_GDIPlus_GraphicsClear($hGfxTrans, 0xFF000000)

Global $hPen1 = _GDIPlus_PenCreate(0x2000AAFF, 2)
_GDIPlus_PenSetMiterLimit($hPen1, 1)
Global $hPen2 = _GDIPlus_PenCreate(0x50FFFFFF, 1)
_GDIPlus_PenSetMiterLimit($hPen2, 1)
Global $hBrush = _GDIPlus_BrushCreateSolid(0x10000000)

Global $hPath = _GDIPlus_PathCreate(0)

While 1
    _Draw()
    Sleep(10)
WEnd


Func _Draw()
    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBmpTrans, 0, 0)

    Local $aValues[4] = [500 - GUICtrlRead($cSlider_1), 500 - GUICtrlRead($cSlider_2), 500 - GUICtrlRead($cSlider_3), 500 - GUICtrlRead($cSlider_4)]
    Local Static $aOldValues[4]

    If $aValues[0] <> $aOldValues[0] Or $aValues[1] <> $aOldValues[1] Or $aValues[2] <> $aOldValues[2] Or $aValues[3] <> $aOldValues[3] Then
        GUICtrlSetData($cLabel_1, $aValues[0])
        GUICtrlSetData($cLabel_2, $aValues[1])
        GUICtrlSetData($cLabel_3, $aValues[2])
        GUICtrlSetData($cLabel_4, $aValues[3])

        Local $fMajorR = $iHeight / 2 - 100
        Local $fMinorR = $aValues[0] / 10
        Local $fDiff = $fMajorR - $fMinorR
        Local $fS = $fDiff / $fMinorR
        Local $fT = 0
        Local $fAngle = $aValues[1] / 10
        Local $fRadFX = $aValues[2] / 2 + $fMinorR
        Local $iStep = $aValues[3] * 2
        Local $X, $Y, $oldX, $oldY
        Local $fMul

        _GDIPlus_PathReset($hPath)
        For $i = 0 To $iStep
            $fMul = $fAngle * $fT
            $X = $fDiff * Sin($fMul) + $fRadFX * Sin($fMul * $fS) + $iWidth / 2
            $Y = $fDiff * Cos($fMul) - $fRadFX * Cos($fMul * $fS) + $iHeight / 2
            $fT += $PI * 4 / $iStep
            If $oldX Then _GDIPlus_PathAddLine($hPath, $oldX, $oldY, $X, $Y)
            $oldX = $X
            $oldY = $Y
        Next
        _GDIPlus_PathFlatten($hPath)
    EndIf

    _GDIPlus_GraphicsDrawPath($hGfxBuffer, $hPath, $hPen1)
    _GDIPlus_GraphicsDrawImage($hGfxTrans, $hBmpBuffer, 0, 0)

    _GDIPlus_GraphicsDrawPath($hGfxBuffer, $hPath, $hPen2)

    $aOldValues = $aValues
    _GDIPlus_GraphicsFillRect($hGfxTrans, 0, 0, $iWidth, $iHeight, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 130, 0)
EndFunc   ;==>_Draw

Func _Exit()
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_GraphicsDispose($hGfxTrans)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpTrans)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGui)
    Exit
EndFunc   ;==>_Exit

HeatMap

;Idea taken from http://js1k.com/demo/156
#include <GDIP.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global $iWidth = 800
Global $iHeight = 580

Global $fSize = 0.2
Global $iRad = 8

Global $aMPos[2] = [0, 0], $aMPos_Old[2] = [0, 0]

_GDIPlus_Startup()

Global $hGui = GUICreate("HeatMap", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT")
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
Global $hBmpHeat = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxHeat = _GDIPlus_ImageGetGraphicsContext($hBmpHeat)
_GDIPlus_GraphicsSetSmoothingMode($hGfxHeat, 2)

_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
GUISetState()

While 1
    $aMPos = _MouseGetPos($hGui)
    If $aMPos[0] > 0 And $aMPos[0] < $iWidth And $aMPos[1] > 0 And $aMPos[1] < $iHeight And ($aMPos[0] <> $aMPos_Old[0] Or $aMPos[1] <> $aMPos_Old[1]) Then
        _DrawHeat($aMPos[0], $aMPos[1])
        $aMPos_Old = $aMPos
    EndIf
WEnd


Func _DrawHeat($iX, $iY)
    $iX = $iX * $fSize
    $iY = $iY * $fSize

    Local $hPath = _GDIPlus_PathCreate(0)
    _GDIPlus_PathAddEllipse($hPath, $iX, $iY, $iRad * 2, $iRad * 2)
    Local $aColor[2] = [1, 0x00000000]
    Local $hPathBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hPathBrush, 0x20000000)
    _GDIPlus_PathBrushSetSurroundColorsWithCount($hPathBrush, $aColor)
    _GDIPlus_GraphicsFillPath($hGfxHeat, $hPath, $hPathBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hPathBrush)

    Local $BitmapData = _GDIPlus_BitmapLockBits($hBmpHeat, $iX, $iY, $iRad * 2, $iRad * 2, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB)
    Local $Stride = DllStructGetData($BitmapData, "Stride")
    Local $Width = DllStructGetData($BitmapData, "Width")
    Local $Height = DllStructGetData($BitmapData, "Height")
    Local $Scan0 = DllStructGetData($BitmapData, "Scan0")
    Local $PixelData, $Color, $Alpha, $R, $G, $B, $Tmp

    For $row = 0 To $Height - 1
        $PixelData = DllStructCreate("dword[" & $Width & ']', $Scan0 + ($row * $Stride))
        For $col = 1 To $Width
            $Color = DllStructGetData($PixelData, 1, $col)

            $Alpha = BitAND(BitShift($Color, 24), 0xFF)
            $R = BitAND(BitShift($Color, 16), 0xFF)
            $G = BitAND(BitShift($Color, 8), 0xFF)
            $B = BitAND($Color, 0xFF)
            Switch $Alpha
                Case 235 To 255
                    $Tmp = 255 - $Alpha
                    $R = 255 - $Tmp
                    $G = $Tmp * 12
                Case 200 To 234
                    $Tmp = 234 - $Alpha
                    $R = 255 - ($Tmp * 8)
                    $G = 255
                Case 150 To 199
                    $Tmp = 199 - $Alpha
                    $G = 255
                    $B = $Tmp * 5
                Case 100 To 149
                    $Tmp = 149 - $Alpha
                    $G = 255 - ($Tmp * 5)
                    $B = 255
                Case Else
                    $B = 255
            EndSwitch
            If $R < 0 Then $R = 0
            If $R > 0xFF Then $R = 0xFF
            If $G < 0 Then $G = 0
            If $G > 0xFF Then $G = 0xFF
            If $B < 0 Then $B = 0
            If $B > 0xFF Then $B = 0xFF
            DllStructSetData($PixelData, 1, BitOR(BitShift($Alpha, -24), BitShift($R, -16), BitShift($G, -8), $B), $col)
        Next
    Next
    _GDIPlus_BitmapUnlockBits($hBmpHeat, $BitmapData)

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBuffer, $hBmpHeat, $iRad, $iRad, $iWidth * $fSize, $iHeight * $fSize, 0, 0, $iWidth, $iHeight)

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_DrawHeat



Func _MouseGetPos($hWnd = 0)
    Local $tPoint = DllStructCreate("long X;long Y")
    Local $aResult = DllCall("user32.dll", "bool", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))
    If @error Then Return SetError(@error, @extended, 0)
    If $hWnd Then _WinAPI_ScreenToClient($hWnd, $tPoint)
    Local $aReturn[2]
    $aReturn[0] = DllStructGetData($tPoint, 1)
    $aReturn[1] = DllStructGetData($tPoint, 2)
    Return $aReturn
EndFunc   ;==>_MouseGetPos



Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
EndFunc   ;==>WM_ERASEBKGND



Func _Exit()
    _GDIPlus_GraphicsDispose($hGfxHeat)
    _GDIPlus_BitmapDispose($hBmpHeat)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

SpiralBitmap

#include <GDIP.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "_EXIT")

$sFile = FileOpenDialog("Open picture", "", "(*.jpg;*.bmp;*.png;*.tif)")
If @error Or Not $sFile Or Not FileExists($sFile) Then Exit

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sFile)
If @error Or Not $hImage Then Exit

$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)

_ResizeImage($hImage, $iWidth, $iHeight, @DesktopWidth * 0.7, @DesktopHeight * 0.7)

$hGui = GUICreate("Test", $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_TRANSPARENT))
GUISetState()


$hPath = _CreateSpiralPath($iWidth, $iHeight, 2, 1.06, 0.05)
$hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, $iWidth / 2, $iHeight / 2)
_GDIPlus_MatrixRotate($hMatrix, -12)
_GDIPlus_MatrixTranslate($hMatrix, -$iWidth / 2, -$iHeight / 2)

While 1
    _DrawImage($hGui, $hImage, $hPath, $hMatrix, $iWidth, $iHeight)
    Sleep(10)
WEnd



Func _ResizeImage(ByRef $hImage, ByRef $iWidth, ByRef $iHeight, $iNewWidth, $iNewHeight)
    Local $fScaleX = $iNewWidth / $iWidth
    Local $fScaleY = $iNewHeight / $iHeight
    If $fScaleY < $fScaleX Then $fScaleX = $fScaleY

    $iWidth *= $fScaleX
    $iHeight *= $fScaleX
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hImage)
    $hImage = $hBitmap
EndFunc   ;==>_ResizeImage




Func _DrawImage($hWnd, $hImage, $hPath, $hMatrix, $iW, $iH)
    Local $tSize = DllStructCreate("long X;long Y")
    DllStructSetData($tSize, "X", $iW)
    DllStructSetData($tSize, "Y", $iH)
    Local $tSource = DllStructCreate("long X;long Y")
    Local $tBlendI = DllStructCreate("byte Op;byte Flags;byte Alpha;byte Format")
    DllStructSetData($tBlendI, "Alpha", 0xFF)
    DllStructSetData($tBlendI, "Format", 1)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    _GDIPlus_PathTransform($hPath, $hMatrix)
    Local $hRegion = _GDIPlus_RegionCreateFromPath($hPath)
    _GDIPlus_GraphicsSetClipRegion($hContext, $hRegion)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawImage($hContext, $hImage, 0, 0)

    Local $hPen = _GDIPlus_PenCreate(0xFF000000, 3)
    _GDIPlus_GraphicsDrawPath($hContext, $hPath, $hPen)
    _GDIPlus_PenDispose($hPen)

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDispose($hGraphics)

    Local $hDCD = _WinAPI_GetDC($hWnd)
    Local $hDCS = _WinAPI_CreateCompatibleDC($hDCD)
    Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Local $hOrig = _WinAPI_SelectObject($hDCS, $hBmp)

    _WinAPI_UpdateLayeredWindow($hWnd, $hDCD, 0, DllStructGetPtr($tSize), $hDCS, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlendI), 2)

    _WinAPI_SelectObject($hDCS, $hOrig)
    _WinAPI_DeleteObject($hBmp)
    _WinAPI_DeleteDC($hDCS)
    _WinAPI_ReleaseDC($hWnd, $hDCD)
EndFunc   ;==>_DrawImage





Func _CreateSpiralPath($iW, $iH, $fSqr = 2, $fMul = 1.1, $fStep = 0.03)
    Local $hPath = _GDIPlus_PathCreate(0)
    Local $iCnt = 0, $iW2 = $iW / 2, $iH2 = $iH / 2
    Local $iX, $iY, $iXOld = $iW2, $iYOld = $iH2
    Do
        $iX = Cos($iCnt) * $iCnt ^ $fSqr + $iW2
        $iY = Sin($iCnt) * $iCnt ^ $fSqr + $iH2
        _GDIPlus_PathAddLine($hPath, $iXOld, $iYOld, $iX, $iY)
        $iXOld = $iX
        $iYOld = $iY
        $iCnt += $fStep
    Until ($iX < 0 Or $iX > $iW) And ($iY < 0 Or $iY > $iH)
    _GDIPlus_PathReverse($hPath)
    $iXOld = $iW2
    $iYOld = $iH2
    $fSqr *= $fMul
    For $i = 0 To $iCnt Step $fStep
        $iX = Cos($i) * $i ^ $fSqr + $iW2
        $iY = Sin($i) * $i ^ $fSqr + $iH2
        _GDIPlus_PathAddLine($hPath, $iXOld, $iYOld, $iX, $iY)
        $iXOld = $iX
        $iYOld = $iY
    Next
    _GDIPlus_PathCloseFigures($hPath)
    _GDIPlus_PathFlatten($hPath)
    Return $hPath
EndFunc   ;==>_CreateSpiralPath




Func _EXIT()
    _GDIPlus_BitmapDispose($hImage)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_EXIT

StarWars

enjoy

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

×
×
  • Create New...