Hi @all
Hab den Theared mal in Script Sammlung von Simon umbenannt damit ich hier mehr einbauen kann
Ich hab mal ein wenig mit gdi plus rum getan und mal ein script mit linien die blinken und einem Quadrat gemacht
Script:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
Global Const $width = 600
Global Const $height = 600
Global $graphics, $backbuffer, $bitmap, $Pen, $i = 10, $bool = 0
Global $title = "Lines and Quadrates by Simon"
Global $color[4] = [0xFF000FFF,0xFFF00000,0xFFFFF000,0xFFF000FF]
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate($title, $width, $height, -1, -1, $WS_POPUP)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()
_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) ;erstelle GDI+ Objekt von der GUI (Grafik)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) ;erstelle Bitmap von der Grafik
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) ;erstelle Grafik Kontext von der Bitmap (dient für die Doppeltbufferung der Grafik, damit die Bewegungen flüssiger aussehen
$pen = _GDIPlus_PenCreate(0, 5) ;erstelle Stift mit der Stärke 4 Pixels
Do
_GDIPlus_GraphicsClear($backbuffer) ;lösche Buffer
_GDIPlus_PenSetColor($Pen, _Color()) ;setze Stiftfarbe ;# weis +++++++++++++++++++++++++
_GDIPlus_GraphicsDrawLine($backbuffer, 10, 10, $i, 10, $Pen) ;ziehe 1. Linie
_GDIPlus_GraphicsDrawLine($backbuffer, 10, 590, 10, 600 - $i, $Pen) ;ziehe 2. Linie
_GDIPlus_GraphicsDrawLine($backbuffer,590,10,590,$i,$Pen);Ziehe 3. Linie
_GDIPlus_GraphicsDrawLine($backbuffer,600 - $i,590,590,590 ,$Pen) ;Ziehe Dritte Linie
;Square
_GdiPlus_PenSEtColor($Pen,_Color())
_GDIPlus_GraphicsDrawLine($backbuffer,$i,10,10,600-$i,$Pen)
_GdiPlus_PenSEtColor($Pen,_Color())
_GDIPlus_GraphicsDrawLine($backbuffer,10,600-$i,600-$i,590,$Pen)
_GdiPlus_PenSEtColor($Pen,_Color())
_GDIPlus_GraphicsDrawLine($backbuffer,590,$i,600 - $i,590,$Pen)
_GdiPlus_PenSEtColor($Pen,_Color())
_GDIPlus_GraphicsDrawLine($backbuffer,$i,10,590,$i,$Pen)
;Square Endet
_GDIPlus_PenSetColor($Pen,0xFFFFFFFF)
;_GDIPlus_GraphicsDrawLine($backbuffer,10,,$Pen)
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) ;das Zeichnen hat im Buffer stattgefunden. Damit das Ganze sichtbar wird, kopiere den Buffer (Bitmap) in den sichtbaren Bereich
If Not $bool And $i < 590 Then
$i += 5
Else
$bool = 1
EndIf
If $bool And $i > 10 Then
$i -= 5
Else
$bool = 0
EndIf
Sleep(40)
Until False
Func close()
_GDIPlus_PenDispose($pen)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()
WinClose($hwnd)
Exit
EndFunc
Func _Color()
$random = Random(0,4)
return '0xFF' & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2)
EndFUnc
Ich hoffe es gefällt euch !
Jetzt das erste noch mit smoothing mode!
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
Global Const $width = 600
Global Const $height = 600
Global $graphics, $backbuffer, $bitmap, $Pen, $i = 10, $bool = 0
Global $title = "Lines and Quadrates by Simon"
Global $color[4] = [0xFF000FFF,0xFFF00000,0xFFFFF000,0xFFF000FF]
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate($title, $width, $height, -1, -1, $WS_POPUP)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()
_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) ;erstelle GDI+ Objekt von der GUI (Grafik)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) ;erstelle Bitmap von der Grafik
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) ;erstelle Grafik Kontext von der Bitmap (dient für die Doppeltbufferung der Grafik, damit die Bewegungen flüssiger aussehen
$pen = _GDIPlus_PenCreate(0, 5) ;erstelle Stift mit der Stärke 4 Pixels
_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2) ; damit wirds noch besser dargestellt
Do
_GDIPlus_GraphicsClear($backbuffer) ;lösche Buffer
_GDIPlus_PenSetColor($Pen, _Color()) ;setze Stiftfarbe ;# weis +++++++++++++++++++++++++
_GDIPlus_GraphicsDrawLine($backbuffer, 10, 10, $i, 10, $Pen) ;ziehe 1. Linie
_GDIPlus_GraphicsDrawLine($backbuffer, 10, 590, 10, 600 - $i, $Pen) ;ziehe 2. Linie
_GDIPlus_GraphicsDrawLine($backbuffer,590,10,590,$i,$Pen);Ziehe 3. Linie
_GDIPlus_GraphicsDrawLine($backbuffer,600 - $i,590,590,590 ,$Pen) ;Ziehe Dritte Linie
;Square
_GdiPlus_PenSEtColor($Pen,_Color())
_GDIPlus_GraphicsDrawLine($backbuffer,$i,10,10,600-$i,$Pen)
_GdiPlus_PenSEtColor($Pen,_Color())
_GDIPlus_GraphicsDrawLine($backbuffer,10,600-$i,600-$i,590,$Pen)
_GdiPlus_PenSEtColor($Pen,_Color())
_GDIPlus_GraphicsDrawLine($backbuffer,590,$i,600 - $i,590,$Pen)
_GdiPlus_PenSEtColor($Pen,_Color())
_GDIPlus_GraphicsDrawLine($backbuffer,$i,10,590,$i,$Pen)
;Square Endet
_GDIPlus_PenSetColor($Pen,0xFFFFFFFF)
;_GDIPlus_GraphicsDrawLine($backbuffer,10,,$Pen)
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) ;das Zeichnen hat im Buffer stattgefunden. Damit das Ganze sichtbar wird, kopiere den Buffer (Bitmap) in den sichtbaren Bereich
If Not $bool And $i < 590 Then
$i += 5
Else
$bool = 1
EndIf
If $bool And $i > 10 Then
$i -= 5
Else
$bool = 0
EndIf
Sleep(40)
Until False
Func close()
_GDIPlus_PenDispose($pen)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()
WinClose($hwnd)
Exit
EndFunc
Func _Color()
$random = Random(0,4)
return '0xFF' & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2)
EndFUnc
wollte erst noch einkleineres in das große quadrat machen aber das hat mir nicht funktioniert!
Hier doch mal was mit Quadraten die immer größer und kleiner werden
Spoiler anzeigen
;Coded by Simon
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
$bool = 10
$w = 580
$r = 1
; Erstellt eine GUI
$hGUI = GUICreate("GDI+", 600, 600, -1, -1, $WS_POPUP)
$hWnd = WinGetHandle("GDI+")
GUISetState()
; Zeichnet eine Linie
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hPen = _GDIPlus_PenCreate()
;_GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst
Do
_WinAPI_RedrawWindow($hGUI)
_GDIPlus_GraphicsClear($hGraphic)
_GDIPlus_PenSetColor($hPen, 0xFFFFFFFF)
;_GDIPlus_GraphicsDrawSquare($hGraphic, $bool, $bool, $w, $w, $hPen)
If $r = 1 Then
For $i = 10 To 270 Step +10
Dim $iColor[4] = [_Color(),_Color(),_Color(),_Color()]
_GDIPlus_GraphicsDrawSquare($hGraphic, $bool + $i, $bool + $i, $w - $i, $w - ($i * 2), $hPen,$iColor)
Next
$r = 2
ElseIf $r = 2 Then
For $i = 10 To 280 Step +20
Dim $iColor[4] = [_Color(),_Color(),_Color(),_Color()]
_GDIPlus_GraphicsDrawSquare($hGraphic, $bool + $i, $bool + $i, $w - $i, $w - ($i * 2), $hPen,$iColor)
Next
$r = 1
EndIf
Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
[/autoit] [autoit][/autoit] [autoit]; Ressourcen freigeben
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_GraphicsDrawSquare
; Description ...: Creates a Square
; Beschreibung ..: Erstellt ein Rechteck
; Syntax.........: _GDIPlus_GraphicsDrawSquare($hGraphic,$iLeft,$iTop,$iWidth,$iHeight,$hPen)
; Parameters ....: $hGraphics - Handle to a Graphics object
; $iLeft = X-Kordinate for the Square
; $iTop = Y-Kordinate for the Square
; $iWidth = Width of the Square
; $iHeight = Hight of the Square
; $hPen = Handel to the Pen
; Return values .: Success - True
; Author ........: Simon Buchner
; ===============================================================================================================================
Func _GDIPlus_GraphicsDrawSquare($hGraphic, $iLeft, $iTop, $iWidth, $iHeight, $hPen,$iColor = Default)
If $iColor = Default Then
Dim $iColor[4] = [0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000]
EndIf
If IsArray($iColor) Then
_GDIPlus_PenSetColor($hPen, $iColor[0])
_GDIPlus_GraphicsDrawLine($hGraphic, $iLeft, $iTop, $iWidth, $iTop, $hPen)
_GDIPlus_PenSetColor($hPen, $iColor[1])
_GDIPlus_GraphicsDrawLine($hGraphic, $iWidth, $iTop, $iWidth, $iTop + $iHeight, $hPen)
_GDIPlus_PenSetColor($hPen, $iColor[2])
_GDIPlus_GraphicsDrawLine($hGraphic, $iLeft, $iTop + $iHeight, $iWidth, $iTop + $iHeight, $hPen)
_GDIPlus_PenSetColor($hPen, $iColor[3])
_GDIPlus_GraphicsDrawLine($hGraphic, $iLeft, $iTop, $iLeft, $iTop + $iHeight, $hPen)
Else
Return -1
EndIf
EndFunc ;==>_GDIPlus_GraphicsDrawSquare
Func _Color()
$random = Random(0, 4)
Return '0xFF' & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2) & Hex(Random(1, 255, 1), 2)
EndFunc ;==>_Color
Hab jezt mal was mit Quadraten gemacht werde es auch noch erweitern
Spoiler anzeigen
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
Global Const $width = 600
Global Const $height = 600
Dim $color[301]
For $ari = 10 To 300 Step +30
$color[$ari] = _Color()
Next
$i = 1
$c = 1
$a = 100
; Erstellt eine GUI
$hGUI = GUICreate("GDI+", 600, 600)
$hWnd = WinGetHandle("GDI+")
GUISetState()
; Zeichnet eine Linie
_GDIPlus_Startup()
$GDI_Buffer = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$Pen = _GDIPlus_PenCreate(0,2)
Do
_WinAPI_RedrawWindow($hGUI)
_GDIPlus_GraphicsClear($GDI_Buffer)
_GDIPlus_PenSetColor($Pen, 0xFFF00000)
For $b = 10 To 300 Step +30
If $c = 1 Then
_GDIPlus_PenSetColor($Pen,$color[$b])
Square($GDI_Buffer,$b, $b,$width,$height, $i,$Pen)
$c = 2
ElseIf $c = 2 Then
_GDIPlus_PenSEtColor($Pen,$color[$b])
Square($GDI_Buffer,$b, $b,$width,$height, $a,$Pen)
$c = 1
EndIf
Next
$i += 50
$a -= 10
Sleep(50)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func Square($hGraphic,$xx1, $yy1,$width,$height, $i,$hPen,$hColor = 0xFFF00000)
;coded by UEZ
;modifided by Simon
Local $degree = 45
Local Const $pi_Div_180 = 4 * ATan(1) / 180
$x1 = $xx1 * Cos(($i + $degree + 0) * $pi_Div_180) + $width / 2
$y1 = $yy1 * Sin(($i + $degree + 0) * $pi_Div_180) + $height / 2
$x2 = $xx1 * Cos(($i + $degree + 90) * $pi_Div_180) + $width / 2
$y2 = $yy1 * Sin(($i + $degree + 90) * $pi_Div_180) + $height / 2
$x3 = $xx1 * Cos(($i + $degree + 180) * $pi_Div_180) + $width / 2
$y3 = $yy1 * Sin(($i + $degree + 180) * $pi_Div_180) + $height / 2
$x4 = $xx1 * Cos(($i + $degree + 270) * $pi_Div_180) + $width / 2
$y4 = $yy1 * Sin(($i + $degree + 270) * $pi_Div_180) + $height / 2
_GDIPlus_GraphicsDrawLine($hGraphic, $x1, $y1, $x2, $y2, $hPen)
_GDIPlus_GraphicsDrawLine($hGraphic, $x2, $y2, $x3, $y3, $hPen)
_GDIPlus_GraphicsDrawLine($hGraphic, $x3, $y3, $x4, $y4, $hPen)
_GDIPlus_GraphicsDrawLine($hGraphic, $x4, $y4, $x1, $y1, $hPen)
EndFunc ;==>Square
Func _Color()
return '0xFF' & Hex(Random(1, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2)
EndFUnc
Ich hoffe UEZ ist mir nicht böse wenn ich seine funktion verändert und verwendet habe
Ich hoffe es gefällt euch auch dieses
gruss Simon