Jump to content

Some Graphical Examples using GDI+ Vol. I


UEZ
 Share

Recommended Posts

I hate you lol. That is so awesome. Here are my 2 modifications to that.

The first is to make it a little faster for slower pcs and I took out the cosin stuff cause I hated trig and calc when I had to take them in school.

CODE
#include <GUIConstantsEx.au3>

#include <GDIplus.au3>

#include <WindowsConstants.au3>

#include <Misc.au3>

#include <Bass.au3>

#include <BassConstants.au3>

$userdll = DllOpen("user32.dll")

$bass_dll = DllOpen("BASS.dll")

Global Const $width = 200

Global Const $height = 230

Global $title = "LMP Visualization"

$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")

_BASS_Init($bass_dll, 0, -1, 44100, 0, "")

$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $file, 0, 0, 0)

If @error Then

MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)

Exit

EndIf

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate($title, $width, $height, -1, -1, Default, $WS_EX_TOOLWINDOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)

$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)

$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

_GDIPlus_GraphicsClear($backbuffer)

$pen1 = _GDIPlus_PenCreate(0, 2)

$pen_size = 4

$pen2 = _GDIPlus_PenCreate(0, $pen_size)

$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)

_BASS_ChannelPlay($bass_dll, $MusicHandle, 1)

$current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)

$percent = Round(($current / $song_length) * 100, 0)

$max_l = 0

$max_r = 0

$fall_speed = 5

$fire_up = 10

Do

$levels = _BASS_ChannelGetLevel($bass_dll, $MusicHandle)

$LeftChLvl = Round(_HiWord($levels) / $height, 0)

$RightChLvl = Round(_LoWord($levels) / $height, 0)

If $max_l <= $LeftChLvl Then

$max_l = $LeftChLvl + $fire_up

Else

If $max_l > $LeftChLvl + $pen_size + 1 Then $max_l -= $fall_speed

EndIf

If $max_r <= $RightChLvl Then

$max_r = $RightChLvl + $fire_up

Else

If $max_r > $RightChLvl + $pen_size + 1 Then $max_r -= $fall_speed

EndIf

_GDIPlus_GraphicsClear($backbuffer, 0x5F000000)

_GDIPlus_PenSetColor($pen2, 0xEF7F7F7F)

For $l = 0 To $leftChLvl Step 2

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $l, $width / 5 + 30, $height - $l, $pen1)

Next

For $l = 0 To $rightChLvl Step 2

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $l, 3 * $width / 5 + 30, $height - $l, $pen1)

Next

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $max_l, $width / 5 + 30, $height - $max_l, $pen2)

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $max_r, 3 * $width / 5 + 30, $height - $max_r, $pen2)

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Sleep(15)

Until False

Func close()

_BASS_Free($bass_dll)

_GDIPlus_PenDispose($pen1)

_GDIPlus_PenDispose($pen2)

_GDIPlus_BitmapDispose($bitmap)

_GDIPlus_GraphicsDispose($graphics)

_GDIPlus_GraphicsDispose($backbuffer)

_GDIPlus_Shutdown()

Exit

EndFunc ;==>close

The second is, I think, Just cooler looking.

CODE
#include <GUIConstantsEx.au3>

#include <GDIplus.au3>

#include <WindowsConstants.au3>

#include <Misc.au3>

#include <Bass.au3>

#include <BassConstants.au3>

$userdll = DllOpen("user32.dll")

$bass_dll = DllOpen("BASS.dll")

Global Const $width = 200

Global Const $height = 230

Global $title = "LMP Visualization"

$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")

_BASS_Init($bass_dll, 0, -1, 44100, 0, "")

$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $file, 0, 0, 0)

If @error Then

MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)

Exit

EndIf

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate($title, $width, $height, -1, -1, Default, $WS_EX_TOOLWINDOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)

$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)

$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

_GDIPlus_GraphicsClear($backbuffer)

$pen1 = _GDIPlus_PenCreate(0, 1)

$pen_size = 4

$pen2 = _GDIPlus_PenCreate(0, $pen_size)

$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)

_BASS_ChannelPlay($bass_dll, $MusicHandle, 1)

$current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)

$percent = Round(($current / $song_length) * 100, 0)

$max_l = 0

$max_r = 0

$fall_speed = 5

$fire_up = 10

Do

$levels = _BASS_ChannelGetLevel($bass_dll, $MusicHandle)

$LeftChLvl = Round(_HiWord($levels) / $height, 0)

$RightChLvl = Round(_LoWord($levels) / $height, 0)

If $max_l <= $LeftChLvl Then

$max_l = $LeftChLvl + $fire_up

Else

If $max_l > $LeftChLvl + $pen_size + 1 Then $max_l -= $fall_speed

EndIf

If $max_r <= $RightChLvl Then

$max_r = $RightChLvl + $fire_up

Else

If $max_r > $RightChLvl + $pen_size + 1 Then $max_r -= $fall_speed

EndIf

_GDIPlus_GraphicsClear($backbuffer, 0x5F000000)

_GDIPlus_PenSetColor($pen2, 0xEF7F7F7F)

For $l = 0 To $leftChLvl Step 5

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $l, $width / 5 + 30, $height - $l, $pen1)

Next

For $l = 0 To $rightChLvl Step 5

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $l, 3 * $width / 5 + 30, $height - $l, $pen1)

Next

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $max_l, $width / 5 + 30, $height - $max_l, $pen2)

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $max_r, 3 * $width / 5 + 30, $height - $max_r, $pen2)

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Sleep(15)

Until False

Func close()

_BASS_Free($bass_dll)

_GDIPlus_PenDispose($pen1)

_GDIPlus_PenDispose($pen2)

_GDIPlus_BitmapDispose($bitmap)

_GDIPlus_GraphicsDispose($graphics)

_GDIPlus_GraphicsDispose($backbuffer)

_GDIPlus_Shutdown()

Exit

EndFunc ;==>close

Giggity

Link to comment
Share on other sites

I hate you lol. That is so awesome. Here are my 2 modifications to that.

The first is to make it a little faster for slower pcs and I took out the cosin stuff cause I hated trig and calc when I had to take them in school.

CODE
#include <GUIConstantsEx.au3>

#include <GDIplus.au3>

#include <WindowsConstants.au3>

#include <Misc.au3>

#include <Bass.au3>

#include <BassConstants.au3>

$userdll = DllOpen("user32.dll")

$bass_dll = DllOpen("BASS.dll")

Global Const $width = 200

Global Const $height = 230

Global $title = "LMP Visualization"

$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")

_BASS_Init($bass_dll, 0, -1, 44100, 0, "")

$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $file, 0, 0, 0)

If @error Then

MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)

Exit

EndIf

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate($title, $width, $height, -1, -1, Default, $WS_EX_TOOLWINDOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)

$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)

$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

_GDIPlus_GraphicsClear($backbuffer)

$pen1 = _GDIPlus_PenCreate(0, 2)

$pen_size = 4

$pen2 = _GDIPlus_PenCreate(0, $pen_size)

$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)

_BASS_ChannelPlay($bass_dll, $MusicHandle, 1)

$current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)

$percent = Round(($current / $song_length) * 100, 0)

$max_l = 0

$max_r = 0

$fall_speed = 5

$fire_up = 10

Do

$levels = _BASS_ChannelGetLevel($bass_dll, $MusicHandle)

$LeftChLvl = Round(_HiWord($levels) / $height, 0)

$RightChLvl = Round(_LoWord($levels) / $height, 0)

If $max_l <= $LeftChLvl Then

$max_l = $LeftChLvl + $fire_up

Else

If $max_l > $LeftChLvl + $pen_size + 1 Then $max_l -= $fall_speed

EndIf

If $max_r <= $RightChLvl Then

$max_r = $RightChLvl + $fire_up

Else

If $max_r > $RightChLvl + $pen_size + 1 Then $max_r -= $fall_speed

EndIf

_GDIPlus_GraphicsClear($backbuffer, 0x5F000000)

_GDIPlus_PenSetColor($pen2, 0xEF7F7F7F)

For $l = 0 To $leftChLvl Step 2

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $l, $width / 5 + 30, $height - $l, $pen1)

Next

For $l = 0 To $rightChLvl Step 2

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $l, 3 * $width / 5 + 30, $height - $l, $pen1)

Next

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $max_l, $width / 5 + 30, $height - $max_l, $pen2)

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $max_r, 3 * $width / 5 + 30, $height - $max_r, $pen2)

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Sleep(15)

Until False

Func close()

_BASS_Free($bass_dll)

_GDIPlus_PenDispose($pen1)

_GDIPlus_PenDispose($pen2)

_GDIPlus_BitmapDispose($bitmap)

_GDIPlus_GraphicsDispose($graphics)

_GDIPlus_GraphicsDispose($backbuffer)

_GDIPlus_Shutdown()

Exit

EndFunc ;==>close

The second is, I think, Just cooler looking.

CODE
#include <GUIConstantsEx.au3>

#include <GDIplus.au3>

#include <WindowsConstants.au3>

#include <Misc.au3>

#include <Bass.au3>

#include <BassConstants.au3>

$userdll = DllOpen("user32.dll")

$bass_dll = DllOpen("BASS.dll")

Global Const $width = 200

Global Const $height = 230

Global $title = "LMP Visualization"

$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")

_BASS_Init($bass_dll, 0, -1, 44100, 0, "")

$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $file, 0, 0, 0)

If @error Then

MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)

Exit

EndIf

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate($title, $width, $height, -1, -1, Default, $WS_EX_TOOLWINDOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)

$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)

$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

_GDIPlus_GraphicsClear($backbuffer)

$pen1 = _GDIPlus_PenCreate(0, 1)

$pen_size = 4

$pen2 = _GDIPlus_PenCreate(0, $pen_size)

$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)

_BASS_ChannelPlay($bass_dll, $MusicHandle, 1)

$current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)

$percent = Round(($current / $song_length) * 100, 0)

$max_l = 0

$max_r = 0

$fall_speed = 5

$fire_up = 10

Do

$levels = _BASS_ChannelGetLevel($bass_dll, $MusicHandle)

$LeftChLvl = Round(_HiWord($levels) / $height, 0)

$RightChLvl = Round(_LoWord($levels) / $height, 0)

If $max_l <= $LeftChLvl Then

$max_l = $LeftChLvl + $fire_up

Else

If $max_l > $LeftChLvl + $pen_size + 1 Then $max_l -= $fall_speed

EndIf

If $max_r <= $RightChLvl Then

$max_r = $RightChLvl + $fire_up

Else

If $max_r > $RightChLvl + $pen_size + 1 Then $max_r -= $fall_speed

EndIf

_GDIPlus_GraphicsClear($backbuffer, 0x5F000000)

_GDIPlus_PenSetColor($pen2, 0xEF7F7F7F)

For $l = 0 To $leftChLvl Step 5

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $l, $width / 5 + 30, $height - $l, $pen1)

Next

For $l = 0 To $rightChLvl Step 5

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $l, 3 * $width / 5 + 30, $height - $l, $pen1)

Next

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $max_l, $width / 5 + 30, $height - $max_l, $pen2)

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $max_r, 3 * $width / 5 + 30, $height - $max_r, $pen2)

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Sleep(15)

Until False

Func close()

_BASS_Free($bass_dll)

_GDIPlus_PenDispose($pen1)

_GDIPlus_PenDispose($pen2)

_GDIPlus_BitmapDispose($bitmap)

_GDIPlus_GraphicsDispose($graphics)

_GDIPlus_GraphicsDispose($backbuffer)

_GDIPlus_Shutdown()

Exit

EndFunc ;==>close

Nice solution for the color gradient - I like it :)

Btw, I have no "slow" pc to test the code.

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

The color gradient took me a second. At first I was thinking the way I had it before, where it was from 0-100 for percentage reasons. Then I had it so the top was red, and the bottom was green, no matter how big or small the bar was. That one looked pretty neat. Then it hit me how to do it when I looked at how you were calculating the right and left values. The sad part is it took me way to long to figure out the green part :). When I got it right I was like how did I not see this lol.

I don't have a slow pc either :-P but I figure drawing all them lines, so I cut the for loop in half, still looks almost as smooth. I just figure going through them for loops would be killer on an older pc.

another modification:

CODE
#include <GUIConstantsEx.au3>

#include <GDIplus.au3>

#include <WindowsConstants.au3>

#include <Misc.au3>

#include <Bass.au3>

#include <BassConstants.au3>

$userdll = DllOpen("user32.dll")

$bass_dll = DllOpen("BASS.dll")

Global Const $width = 200

Global Const $height = 230

Global $title = "LMP Visualization"

$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")

_BASS_Init($bass_dll, 0, -1, 44100, 0, "")

$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $file, 0, 0, 0)

If @error Then

MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)

Exit

EndIf

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate($title, $width, $height, -1, -1, Default, $WS_EX_TOOLWINDOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)

$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)

$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

_GDIPlus_GraphicsClear($backbuffer)

$pen1 = _GDIPlus_PenCreate(0, 1)

$pen_size = 4

$pen2 = _GDIPlus_PenCreate(0, $pen_size)

$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)

_BASS_ChannelPlay($bass_dll, $MusicHandle, 1)

$current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)

$percent = Round(($current / $song_length) * 100, 0)

$max_l = 0

$max_r = 0

$fall_speed = 5

$fire_up = 10

Do

$levels = _BASS_ChannelGetLevel($bass_dll, $MusicHandle)

$LeftChLvl = Round(_HiWord($levels) / $height, 0)

$RightChLvl = Round(_LoWord($levels) / $height, 0)

If $max_l <= $LeftChLvl Then

$max_l = $LeftChLvl + $fire_up

Else

If $max_l > $LeftChLvl + $pen_size + 1 Then $max_l -= $fall_speed

EndIf

If $max_r <= $RightChLvl Then

$max_r = $RightChLvl + $fire_up

Else

If $max_r > $RightChLvl + $pen_size + 1 Then $max_r -= $fall_speed

EndIf

_GDIPlus_GraphicsClear($backbuffer, 0x5F000000)

_GDIPlus_PenSetColor($pen2, 0xEF7F7F7F)

$pen1 = _GDIPlus_PenCreate(0, 2)

For $l = 0 To $leftChLvl Step 2 + (($leftchlvl/$height)*10)

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $l, $width / 5 + 30, $height - $l, $pen1)

Next

For $l = 0 To $rightChLvl Step 2 + (($rightchlvl/$height)*10)

$r = $l/($height) * 256

$g = 256 - $r

$b = 0

_GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $l, 3 * $width / 5 + 30, $height - $l, $pen1)

Next

_GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $max_l, $width / 5 + 30, $height - $max_l, $pen2)

_GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $max_r, 3 * $width / 5 + 30, $height - $max_r, $pen2)

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

_GDIPlus_PenDispose($pen1)

Sleep(15)

Until False

Func close()

_BASS_Free($bass_dll)

_GDIPlus_PenDispose($pen1)

_GDIPlus_PenDispose($pen2)

_GDIPlus_BitmapDispose($bitmap)

_GDIPlus_GraphicsDispose($graphics)

_GDIPlus_GraphicsDispose($backbuffer)

_GDIPlus_Shutdown()

Exit

EndFunc ;==>close

Giggity

Link to comment
Share on other sites

  • 2 weeks later...

youknowwho4eva inspired me to create another visualization (Analog Meter) :P :

Download compiled version + source code here: CLICK ME or check out my 1st post.

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

@UEZ

Seems to be nice but my script crashes at start :P

Cheers, FireFox.

Hmmm, sounds strange! Did you download it from my post #84 and tried it from there?

The posted source code alone will not work!

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

Here some GDI+ examples made for fun (my 1st GDI+ codes):

Just found this post - You are a GDI god. :P

One note though, on the "L-System Fractals" example it seems very slow until I changed the GraphicsClear.

- something about continually redrawing a non-opaque background just isn't quick for me.

Could just be my hardware though.

0xFFFFFFFF (opaque white) seemed to work quickly as a workaround.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Just found this post - You are a GDI god. :(

One note though, on the "L-System Fractals" example it seems very slow until I changed the GraphicsClear.

- something about continually redrawing a non-opaque background just isn't quick for me.

Could just be my hardware though.

0xFFFFFFFF (opaque white) seemed to work quickly as a workaround.

Thanks for feedback!

I thought that I've updated the code with it but it is still an older version - maybe in the downloads is the updated version :unsure: -=> Updated ;)

The issue with the "L-System Fractals" is the recursion. Recursion with AutoIt is very slow (look here)

A simple example with Fibonacci numbers for demonstration:

$n = 25

$bench_start = TimerInit()
ConsoleWrite(Fibonacci_i($n)  & @CRLF)
$bench_end_i = Round(TimerDiff($bench_start), 4)

$bench_start = TimerInit()
ConsoleWrite(Fibonacci_r($n) & @CRLF)
$bench_end_r = Round(TimerDiff($bench_start), 4)

ConsoleWrite(@CRLF & "Iterative: " & $bench_end_i & " ms" & @CRLF & "Recursive: " & $bench_end_r & " ms" & @CRLF & "Diff: " & Abs($bench_end_i - $bench_end_r) & " ms !" & @CRLF & @CRLF)

Func Fibonacci_i($f)
    Dim $arr_fib[3]
    $arr_fib[0] = 0
    $arr_fib[1] = 1
    For $i = 2 To $f
        $arr_fib[2] = $arr_fib[1] + $arr_fib[0]
        $arr_fib[0] = $arr_fib[1]
        $arr_fib[1] = $arr_fib[2]
    Next
    Return $arr_fib[2]
EndFunc

Func Fibonacci_r($f)
    If $f = 0 Then Return 0
    If $f = 1 Then Return 1
    Return Fibonacci_r($f - 1) + Fibonacci_r($f - 2)
EndFunc

If you tough enough try to convert L-System Fractals recursion to iteration ;)

These are simple GDI+ examples, so surely I'm not a GDI+ god :D Mostly the challenge is the mathematics... :P

Currently I'm trying to rotate a 3D cube with (3x3x3) balls but this is cracking my brain... :D

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 forgotten to add also BassConstants.au3 which will be loaded by Bass.au3! Thanks to GtaSpider for the hint :P

I will update the download resource soon... Done.

Sorry,

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

UEZ, awesome job :unsure: I like the mesmerizing screensaver.. and the sinus scroller was cool for about a minute haha :P Really good job overall

Link to comment
Share on other sites

Wow, no kidding about recursive being SLOW.

Results from that bench test:

75025

75025

Iterative: 0.8227 ms

Recursive: 943.8691 ms

Diff: 943.0464 ms !

Iterative is over 1000x faster than recursive.

Edit:

Hmm thinking about this its not entirely autoits fault that the recursive method is slow. If you draw out the recursive tree it doubles the number of functions that are called for each increase of n so that auto it calls the recursive function about 2^n times where as the iterative method only adds a single iteration per increase of n the the work load is n.

Edited by smstroble

MUHAHAHAHAHA

Link to comment
Share on other sites

UEZ, awesome job :unsure: I like the mesmerizing screensaver.. and the sinus scroller was cool for about a minute haha :P Really good job overall

Thanks for your feedback! :D

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

Wow, no kidding about recursive being SLOW.

Results from that bench test:

75025

75025

Iterative: 0.8227 ms

Recursive: 943.8691 ms

Diff: 943.0464 ms !

Iterative is over 1000x faster than recursive.

Edit:

Hmm thinking about this its not entirely autoits fault that the recursive method is slow. If you draw out the recursive tree it doubles the number of functions that are called for each increase of n so that auto it calls the recursive function about 2^n times where as the iterative method only adds a single iteration per increase of n the the work load is n.

Yes, of course the runtime depends on the recursion depth and probably has exponential runtime as you mentioned (O(2^n)) but fact is that recursion is much slower than iteration! The challenge is to convert the fractals from recursion to iteration to speed it up.

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...

Hope you don't mind me lending your thread a little, but I just made this little animation and I don't think it qualifies in its own thread.

Posted Image

CODE
#include <GUIConstantsEx.au3>

#include <GDIPlus.au3>

Opt("GUIOnEventMode", 1)

Global Const $width = 800

Global Const $height = 500

$hWnd = GUICreate("SineWorm", $width, $height)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)

$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)

$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

_GDIPlus_GraphicsSetSmoothingMode($backbuffer,4)

$inc = 0

Local $aFact[4] = [0.0, 0.25, 0.5, 1]

$lgbrush = _GDIPlus_CreateLineBrushFromRect(0, 00, $width, $height, $aFact, -1, 0xFF00FF00, 0xFF0000FF,0)

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Cos($inc / 2+$i/25) * 100

$ymod = Sin($inc / 2+$i/25) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

Func close()

_GDIPlus_BrushDispose($lgbrush)

_GDIPlus_GraphicsDispose($backbuffer)

_GDIPlus_BitmapDispose($bitmap)

_GDIPlus_GraphicsDispose($graphics)

_GDIPlus_Shutdown()

Exit

EndFunc ;==>close

;==== GDIPlus_CreateLineBrushFromRect ===

;Description - Creates a LinearGradientBrush object from a set of boundary points and boundary colors.

; $aFactors - If non-array, default array will be used.

; Pointer to an array of real numbers that specify blend factors. Each number in the array

; specifies a percentage of the ending color and should be in the range from 0.0 through 1.0.

;$aPositions - If non-array, default array will be used.

; Pointer to an array of real numbers that specify blend factors' positions. Each number in the array

; indicates a percentage of the distance between the starting boundary and the ending boundary

; and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the

; gradient and 1.0 indicates the ending boundary. There must be at least two positions

; specified: the first position, which is always 0.0, and the last position, which is always

; 1.0. Otherwise, the behavior is undefined. A blend position between 0.0 and 1.0 indicates a

; line, parallel to the boundary lines, that is a certain fraction of the distance from the

; starting boundary to the ending boundary. For example, a blend position of 0.7 indicates

; the line that is 70 percent of the distance from the starting boundary to the ending boundary.

; The color is constant on lines that are parallel to the boundary lines.

; $iArgb1 - First Top color in 0xAARRGGBB format

; $iArgb2 - Second color in 0xAARRGGBB format

; $LinearGradientMode - LinearGradientModeHorizontal = 0x00000000,

; LinearGradientModeVertical = 0x00000001,

; LinearGradientModeForwardDiagonal = 0x00000002,

; LinearGradientModeBackwardDiagonal = 0x00000003

; $WrapMode - WrapModeTile = 0,

; WrapModeTileFlipX = 1,

; WrapModeTileFlipY = 2,

; WrapModeTileFlipXY = 3,

; WrapModeClamp = 4

; GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ARGB color1, ARGB color2,

; LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient)

; Reference: http://msdn.microsoft.com/en-us/library/ms534043(VS.85).aspx

;

Func _GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _

$iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount

If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF

If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000

If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001

If $WrapMode = -1 Then $WrapMode = 1

$tRect = DllStructCreate("float X;float Y;float Width;float Height")

$pRect = DllStructGetPtr($tRect)

DllStructSetData($tRect, "X", $iX)

DllStructSetData($tRect, "Y", $iY)

DllStructSetData($tRect, "Width", $iWidth)

DllStructSetData($tRect, "Height", $iHeight)

;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined

$aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _

"int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)

If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]

If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]

$iCount = UBound($aPositions)

$tFactors = DllStructCreate("float[" & $iCount & "]")

$pFactors = DllStructGetPtr($tFactors)

For $iI = 0 To $iCount - 1

DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)

Next

$tPositions = DllStructCreate("float[" & $iCount & "]")

$pPositions = DllStructGetPtr($tPositions)

For $iI = 0 To $iCount - 1

DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)

Next

$hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _

"ptr", $pFactors, "ptr", $pPositions, "int", $iCount)

Return $aRet[6]; Handle of Line Brush

EndFunc ;==>_GDIPlus_CreateLineBrushFromRect

:P

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Nice work monoceres (as usual) :P

Of course I don't mind when other members are posting their examples into this thread!

Btw, I made some updates to the Analog Meter code -> you can now open a song by pressing O, pause the song with P and continue it with C (look to the 1st post)!

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

Here another small one!

Particle Catapult:

Source code moved to my 1st post!

I don't know whether you want to see more of this kind of examples or just saying "STOP, no more boring stuff"!

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

Hope you don't mind me lending your thread a little, but I just made this little animation and I don't think it qualifies in its own thread.

Posted Image

CODE
#include <GUIConstantsEx.au3>

#include <GDIPlus.au3>

Opt("GUIOnEventMode", 1)

Global Const $width = 800

Global Const $height = 500

$hWnd = GUICreate("SineWorm", $width, $height)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)

$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)

$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

_GDIPlus_GraphicsSetSmoothingMode($backbuffer,4)

$inc = 0

Local $aFact[4] = [0.0, 0.25, 0.5, 1]

$lgbrush = _GDIPlus_CreateLineBrushFromRect(0, 00, $width, $height, $aFact, -1, 0xFF00FF00, 0xFF0000FF,0)

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Cos($inc / 2+$i/25) * 100

$ymod = Sin($inc / 2+$i/25) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

Func close()

_GDIPlus_BrushDispose($lgbrush)

_GDIPlus_GraphicsDispose($backbuffer)

_GDIPlus_BitmapDispose($bitmap)

_GDIPlus_GraphicsDispose($graphics)

_GDIPlus_Shutdown()

Exit

EndFunc ;==>close

;==== GDIPlus_CreateLineBrushFromRect ===

;Description - Creates a LinearGradientBrush object from a set of boundary points and boundary colors.

; $aFactors - If non-array, default array will be used.

; Pointer to an array of real numbers that specify blend factors. Each number in the array

; specifies a percentage of the ending color and should be in the range from 0.0 through 1.0.

;$aPositions - If non-array, default array will be used.

; Pointer to an array of real numbers that specify blend factors' positions. Each number in the array

; indicates a percentage of the distance between the starting boundary and the ending boundary

; and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the

; gradient and 1.0 indicates the ending boundary. There must be at least two positions

; specified: the first position, which is always 0.0, and the last position, which is always

; 1.0. Otherwise, the behavior is undefined. A blend position between 0.0 and 1.0 indicates a

; line, parallel to the boundary lines, that is a certain fraction of the distance from the

; starting boundary to the ending boundary. For example, a blend position of 0.7 indicates

; the line that is 70 percent of the distance from the starting boundary to the ending boundary.

; The color is constant on lines that are parallel to the boundary lines.

; $iArgb1 - First Top color in 0xAARRGGBB format

; $iArgb2 - Second color in 0xAARRGGBB format

; $LinearGradientMode - LinearGradientModeHorizontal = 0x00000000,

; LinearGradientModeVertical = 0x00000001,

; LinearGradientModeForwardDiagonal = 0x00000002,

; LinearGradientModeBackwardDiagonal = 0x00000003

; $WrapMode - WrapModeTile = 0,

; WrapModeTileFlipX = 1,

; WrapModeTileFlipY = 2,

; WrapModeTileFlipXY = 3,

; WrapModeClamp = 4

; GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ARGB color1, ARGB color2,

; LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient)

; Reference: http://msdn.microsoft.com/en-us/library/ms534043(VS.85).aspx

;

Func _GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _

$iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount

If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF

If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000

If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001

If $WrapMode = -1 Then $WrapMode = 1

$tRect = DllStructCreate("float X;float Y;float Width;float Height")

$pRect = DllStructGetPtr($tRect)

DllStructSetData($tRect, "X", $iX)

DllStructSetData($tRect, "Y", $iY)

DllStructSetData($tRect, "Width", $iWidth)

DllStructSetData($tRect, "Height", $iHeight)

;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined

$aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _

"int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)

If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]

If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]

$iCount = UBound($aPositions)

$tFactors = DllStructCreate("float[" & $iCount & "]")

$pFactors = DllStructGetPtr($tFactors)

For $iI = 0 To $iCount - 1

DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)

Next

$tPositions = DllStructCreate("float[" & $iCount & "]")

$pPositions = DllStructGetPtr($tPositions)

For $iI = 0 To $iCount - 1

DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)

Next

$hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _

"ptr", $pFactors, "ptr", $pPositions, "int", $iCount)

Return $aRet[6]; Handle of Line Brush

EndFunc ;==>_GDIPlus_CreateLineBrushFromRect

:D
If you switch around the functions you get some other really neat results. (lines 28 and 29) I changed them both to Tangent, that was pretty neat. I tried a few others. All were really interesting. I think my favorite is

$xmod = Sin($inc / 2+$i/25) * 100
$ymod = Tan($inc / 2+$i/25) * 100

Edit: Made this for quick switching. use 1-9 to switch it up. also changed the math up a little.

CODE
#include <GUIConstantsEx.au3>

#include <GDIPlus.au3>

HotKeySet("1","tantan")

HotKeySet("2","tancos")

HotKeySet("3","tansin")

HotKeySet("4","sintan")

HotKeySet("5","costan")

HotKeySet("6","sinsin")

HotKeySet("7","sincos")

HotKeySet("8","coscos")

HotKeySet("9","cossin")

Opt("GUIOnEventMode", 1)

Global Const $width = 800

Global Const $height = 500

$hWnd = GUICreate("SineWorm", $width, $height)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

GUISetState()

_GDIPlus_Startup()

$graphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)

$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)

$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

_GDIPlus_GraphicsSetSmoothingMode($backbuffer,4)

$inc = 0

Local $aFact[4] = [0.0, 0.25, 0.5, 1]

$lgbrush = _GDIPlus_CreateLineBrushFromRect(0, 00, $width, $height, $aFact, -1, 0xFF00FF00, 0xFF0000FF,0)

tantan()

Func tantan()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Tan($inc / 2+$i/15) * 200

$ymod = Tan($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func tancos()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Tan($inc / 2+$i/15) * 200

$ymod = Cos($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func tansin()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Tan($inc / 2+$i/15) * 200

$ymod = Sin($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func sintan()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Sin($inc / 2+$i/15) * 200

$ymod = Tan($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func costan()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Cos($inc / 2+$i/15) * 200

$ymod = Tan($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func sinsin()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Sin($inc / 2+$i/15) * 200

$ymod = Sin($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func sincos()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Sin($inc / 2+$i/15) * 200

$ymod = Cos($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func coscos()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Cos($inc / 2+$i/15) * 200

$ymod = Cos($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func cossin()

Do

_GDIPlus_GraphicsClear($backbuffer, 0xFF000000)

$inc += 0.15

For $i = 125 To $width - 125 Step 6

$xmod = Cos($inc / 2+$i/15) * 200

$ymod = Sin($inc / 2+$i/5) * 100

_GDIPlus_GraphicsFillEllipse($backbuffer, $xmod + $i + 10, $ymod + $height / 2 - 25 + Sin($inc + $i / 100) * 0, 8, 8, $lgbrush)

Next

_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)

Until Not Sleep(20)

EndFunc

Func close()

_GDIPlus_BrushDispose($lgbrush)

_GDIPlus_GraphicsDispose($backbuffer)

_GDIPlus_BitmapDispose($bitmap)

_GDIPlus_GraphicsDispose($graphics)

_GDIPlus_Shutdown()

Exit

EndFunc ;==>close

;==== GDIPlus_CreateLineBrushFromRect ===

;Description - Creates a LinearGradientBrush object from a set of boundary points and boundary colors.

; $aFactors - If non-array, default array will be used.

; Pointer to an array of real numbers that specify blend factors. Each number in the array

; specifies a percentage of the ending color and should be in the range from 0.0 through 1.0.

;$aPositions - If non-array, default array will be used.

; Pointer to an array of real numbers that specify blend factors' positions. Each number in the array

; indicates a percentage of the distance between the starting boundary and the ending boundary

; and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the

; gradient and 1.0 indicates the ending boundary. There must be at least two positions

; specified: the first position, which is always 0.0, and the last position, which is always

; 1.0. Otherwise, the behavior is undefined. A blend position between 0.0 and 1.0 indicates a

; line, parallel to the boundary lines, that is a certain fraction of the distance from the

; starting boundary to the ending boundary. For example, a blend position of 0.7 indicates

; the line that is 70 percent of the distance from the starting boundary to the ending boundary.

; The color is constant on lines that are parallel to the boundary lines.

; $iArgb1 - First Top color in 0xAARRGGBB format

; $iArgb2 - Second color in 0xAARRGGBB format

; $LinearGradientMode - LinearGradientModeHorizontal = 0x00000000,

; LinearGradientModeVertical = 0x00000001,

; LinearGradientModeForwardDiagonal = 0x00000002,

; LinearGradientModeBackwardDiagonal = 0x00000003

; $WrapMode - WrapModeTile = 0,

; WrapModeTileFlipX = 1,

; WrapModeTileFlipY = 2,

; WrapModeTileFlipXY = 3,

; WrapModeClamp = 4

; GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ARGB color1, ARGB color2,

; LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient)

; Reference: http://msdn.microsoft.com/en-us/library/ms534043(VS.85).aspx

;

Func _GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _

$iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount

If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF

If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000

If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001

If $WrapMode = -1 Then $WrapMode = 1

$tRect = DllStructCreate("float X;float Y;float Width;float Height")

$pRect = DllStructGetPtr($tRect)

DllStructSetData($tRect, "X", $iX)

DllStructSetData($tRect, "Y", $iY)

DllStructSetData($tRect, "Width", $iWidth)

DllStructSetData($tRect, "Height", $iHeight)

;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined

$aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _

"int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)

If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]

If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]

$iCount = UBound($aPositions)

$tFactors = DllStructCreate("float[" & $iCount & "]")

$pFactors = DllStructGetPtr($tFactors)

For $iI = 0 To $iCount - 1

DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)

Next

$tPositions = DllStructCreate("float[" & $iCount & "]")

$pPositions = DllStructGetPtr($tPositions)

For $iI = 0 To $iCount - 1

DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)

Next

$hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _

"ptr", $pFactors, "ptr", $pPositions, "int", $iCount)

Return $aRet[6]; Handle of Line Brush

EndFunc ;==>_GDIPlus_CreateLineBrushFromRect

Edited by youknowwho4eva

Giggity

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...