Hier mal ein paar Beispiele für Spielereien mit dem Graphic Control ^^. Die Graphic-Befehle habe ich processing-ähnlich vereinfacht.
Beispiele
Ball mit Kollision, minx
[autoit]#include <processing.au3>
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Local $Width = 500, $Height = 300
Local $Radius = 20, $Speed = 5
Local $x = Random(0, $Width-$Radius*2, 1), $y = Random(0, $Height-$Radius*2, 1), $ax = $Speed, $ay = $Speed
$hGUI = GUICreate("processing: Ball with collision [minx]", $Width, $Height, -1, -1, -1, $GR_DBUFFER)
GUISetOnEvent(-3, "quit")
$hGraphics = size($Width,$Height)
color()
GUISetState()
While Sleep(10)
$hBuffer = buffer($hGraphics)
$hGraphics = size($Width, $Height)
$x += $ax
$y += $ay
If $x > $Width - $Radius*2 Or $x <= 0 Then $ax *= -1
If $y > $Height - $Radius*2 Or $y <= 0 Then $ay *= -1
pen($hGraphics, 0xFFFFFF, 0xFFFFFF)
ellipse($hGraphics, $x, $y, $Radius*2, $Radius*2)
clearbuffer($hBuffer)
WEnd
Mehr Bälle mit Kollision, minx
[autoit]#include <processing.au3>
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Local $Balls = 20
Local $Width = 500, $Height = 300
Local $Radius = 20, $Speed = 3
Local $ax = $Speed, $ay = $Speed
Local $aBalls[$Balls][4] ; [nBall][x, y, ax, ay]
For $i = 0 To $Balls - 1
$aBalls[$i][0] = Random(0, $Width-$Radius*2, 1)
$aBalls[$i][1] = Random(0, $Height-$Radius*2, 1)
$aBalls[$i][2] = $ax
$aBalls[$i][3] = $ay
Next
$hGUI = GUICreate("processing: n Balls with collision [minx]", $Width, $Height, -1, -1, -1, $GR_DBUFFER)
GUISetOnEvent(-3, "quit")
$hGraphics = size($Width,$Height)
color()
GUISetState()
While Sleep(10)
$hBuffer = buffer($hGraphics)
$hGraphics = size($Width, $Height)
pen($hGraphics, 0x000000, 0xFFFFFF)
For $i = 0 To $Balls -1
$aBalls[$i][0] += $aBalls[$i][2]
$aBalls[$i][1] += $aBalls[$i][3]
If $aBalls[$i][0] > $Width - $Radius*2 Or $aBalls[$i][0] <= 0 Then $aBalls[$i][2] *= -1
If $aBalls[$i][1] > $Height - $Radius*2 Or $aBalls[$i][1] <= 0 Then $aBalls[$i][3] *= -1
ellipse($hGraphics, $aBalls[$i][0], $aBalls[$i][1], $Radius*2, $Radius*2)
Next
clearbuffer($hBuffer)
WEnd
Offene und automatisch geschlossene Linien / Polygone, minx
[autoit]#include <processing.au3>
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Local $Width = 500, $Height = 300, $Radius = 100
[/autoit] [autoit][/autoit] [autoit]$hGUI = GUICreate("processing: Open and closed lines [minx]", $Width, $Height, -1, -1, -1, $GR_DBUFFER)
GUISetOnEvent(-3, "quit")
$hGraphics = size($Width,$Height)
color()
GUISetState()
While Sleep(10)
$hBuffer = buffer($hGraphics)
$hGraphics = size($Width, $Height)
pensize($hGraphics, 2)
pen($hGraphics, 0xFFFFFF, $GR_TRANS) ;You MUST specify $GR_TRANS as filling color, or the drawing WILL be closed
move($hGraphics, 5, 5)
linestep($hGraphics, 30, 30)
linestep($hGraphics, 100, 30)
linestep($hGraphics, 110, 40)
linestep($hGraphics, 100, 50)
linestep($hGraphics, 30, 50)
linestep($hGraphics, 5, 75)
linestep($hGraphics, 5, 5)
pen($hGraphics, 0x0000FF, 0xF0F0F0); Because we specified a filling color, the drawing closes itself (endpoint = startpoint)
move($hGraphics, 5, 105)
linestep($hGraphics, 30, 130)
linestep($hGraphics, 100, 130)
linestep($hGraphics, 110, 140)
linestep($hGraphics, 100, 150)
linestep($hGraphics, 30, 150)
linestep($hGraphics, 5, 175)
clearbuffer($hBuffer)
WEnd
Bezier Tropfen, minx
[autoit]#include <processing.au3>
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Local $Width = 500, $Height = 300
Local $Left = 50, $Top = 50, $Field = 20
$hGUI = GUICreate("processing: Bezier [minx]", $Width, $Height, -1, -1, -1, $GR_DBUFFER)
GUISetOnEvent(-3, "quit")
$hGraphics = size($Width,$Height)
color()
GUISetState()
While Sleep(10)
$hBuffer = buffer($hGraphics)
$hGraphics = size($Width, $Height)
pen($hGraphics, 0x000000, 0xFF00FF)
bezier($hGraphics, $Width/2, 180, ($Width/2)-150, 0, ($Width/2)+150, 0)
clearbuffer($hBuffer)
WEnd
Rechteck Display, minx
[autoit]#include <processing.au3>
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Local $Width = 170, $Height = 200, $Radius = 100
Dim $aBlocks[6][16] = [ [1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0], _
[0,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0], _
[0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0], _
[0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0], _
[0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0], _
[0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0] _
]
;
Local $rB = Random(0, 5, 1)
$hGUI = GUICreate("processing: Display Tetris blocks [minx]", $Width, $Height, -1, -1, -1, $GR_DBUFFER)
GUISetOnEvent(-3, "quit")
GUICtrlCreateButton("Random", 5, 170, 160, 25)
GUICtrlSetOnEvent(-1, "rand")
$hGraphics = size($Width,$Height)
color()
GUISetState()
While Sleep(10)
$hBuffer = buffer($hGraphics)
$hGraphics = size($Width, $Height)
$iC = -1
For $y = 5 To (5+3*40) Step 40
For $x = 5 To (5+3*40) Step 40
$iC += 1
If $aBlocks[$rB][$iC] = 0 Then
pen($hGraphics, 0x808080, 0x8080F0)
rect($hGraphics, $x, $y, 40, 40)
ElseIf $aBlocks[$rB][$iC] = 1 Then
pen($hGraphics, 0x808080, 0xFFFFFF)
rect($hGraphics, $x, $y, 40, 40)
EndIf
Next
Next
clearbuffer($hBuffer)
WEnd
Func rand()
$_i = $rB
do
$i = Random(0, 5, 1)
Until $i <> $_i
Global $rB = $i
EndFunc
Pacman Animation, minx
[autoit]#include <processing.au3>
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Local $Width = 500, $Height = 300, $Radius = 100
Local $Mouth = 20, $rSweep = 360 - $Mouth*2, $rStart = (180-$Mouth)*-1
Local $iAdd = 1, $x = $Width + $Radius
$hGUI = GUICreate("processing: Pacman animation [minx]", $Width, $Height, -1, -1, -1, $GR_DBUFFER)
GUISetOnEvent(-3, "quit")
$hGraphics = size($Width,$Height)
color()
GUISetState()
While Sleep(10)
$hBuffer = buffer($hGraphics)
$hGraphics = size($Width, $Height)
$x -= 2
$Mouth += $iAdd
If $Mouth >= 40 Then $iAdd = -1
If $Mouth <= 1 Then $iAdd = 1
If $x + $Radius < 0 Then $x = $Width + $Radius
$rSweep = 360 - $Mouth*2
$rStart = (180-$Mouth)*-1
pensize($hGraphics, 5)
pen($hGraphics, 0x000000, 0xFFFF00)
pie($hGraphics, $x, $Height/2, $Radius, $rStart, $rSweep)
clearbuffer($hBuffer)
WEnd
Pacman Potentiometer
[autoit]#include <processing.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Local $Width = 500, $Height = 300, $Radius = 100
Local $Mouth = 10, $rSweep = 360 - $Mouth*2, $rStart = (180-$Mouth)*-1
Local $iAdd = 1, $x = $Width + $Radius
Local $Titel = "processing: Pacman Potentiometer [minx]"
Local $hGUI = GUICreate($Titel, $Width, $Height, -1, -1, -1, $GR_DBUFFER)
GUISetOnEvent(-3, "quit")
$hGraphics = size($Width,$Height)
color()
GUISetState()
Local $aWin = WinGetPos($Titel), $Left = $aWin[0], $Top = $aWin[1]
[/autoit] [autoit][/autoit] [autoit]While Sleep(10)
If IsPointInCircle($Width/2, $Height/2, $Radius, (MouseGetPos(0)-$Left), (MouseGetPos(1)-$Top-30)) And _IsPressed("01") Then
$Mouth = ((($Width/2+$Radius)-(MouseGetPos(0)-$Left))/($Width/2+$Radius)) * 320
$rSweep = 360 - $Mouth*2
$rStart = (180-$Mouth)*-1
EndIf
ToolTip(Int((($Mouth/360)*2)*100))
$hBuffer = buffer($hGraphics)
$hGraphics = size($Width, $Height)
pensize($hGraphics, 5)
pen($hGraphics, 0x000000, 0xFFFF00)
pie($hGraphics, $Width/2, $Height/2, $Radius, $rStart, $rSweep)
clearbuffer($hBuffer)
WEnd
Func IsPointInCircle(Const $Xm, Const $Ym, Const $R, Const $Xp, Const $Yp)
Return ($Xp - $Xm) ^ 2 + ($Yp - $Ym) ^ 2 <= $R ^ 2
EndFunc ;==>IsPointInCircle
Cloth Simulation, UEZ
[autoit]#include <processing.au3>
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{SPACE}", "Gravity")
[/autoit] [autoit][/autoit] [autoit]Local Const $iX = Int(@DesktopWidth * 0.66), $iY = Int($iX * 10 / 16)
Local Const $W2 = $iX / 2, $H2 = $iY / 2
$hGUI = GUICreate("processing: Cloth Simulation [UEZ] (Space to take away gravity)", $iX, $iY, -1, -1, -1, $GR_DBUFFER)
GUISetOnEvent(-3, "quit")
$hGraphics = size($iX, $iY)
color()
GUISetState()
Local Const $f = 10
Local Const $ff = $f ^ 2
Local $k[$f][$f][5];f,f,px,py,m,k,j
Local $l[$f ^ 2 + ($f -1) ^ 2][4]
Local $q = 0
Local $r = 0.00125
Local $o = 1
Local $y = 0.05
Local $z = 0
Local Const $u = 0.08
Local Const $gg = $iX * 1.20
Local Const $jj = $iY * 0.95
Local $x, $h, $i
For $h = 0 To $f - 1
$x = 0.05
For $i = 0 To $f - 1
$k[$h][$i][0] = $x ;px
$k[$h][$i][1] = $y ;py
$k[$h][$i][2] = 1 ;m
$k[$h][$i][3] = $x ;k
$k[$h][$i][4] = $y ;j
If $h > 0 Then
$l[$z][0] = $h - 1
$l[$z][1] = $i
$l[$z][2] = $h
$l[$z][3] = $i
$z += 1
EndIf
If $i > 0 Then
$l[$z][0] = $h
$l[$z][1] = $i - 1
$l[$z][2] = $h
$l[$z][3] = $i
$z += 1
EndIf
$x += $u
Next
$y += $u
Next
$k[0][0][2] = 0
$k[0][$f - 1][2] = 0
While Sleep(10)
Simulate()
WEnd
Func Simulate()
$hBuffer = buffer($hGraphics)
$hGraphics = size($iX, $iY)
pen($hGraphics, 0xFFFFFF)
Local $nx, $ny, $a, $s, $t, $dx, $dy, $de, $di
Local $x1, $y1, $x2, $y2, $spm, $tpm, $spx, $spy, $tpx, $tpy
Local $pm, $px, $py, $pk, $pj, $_hGraphics
For $h = 0 To $f - 1
For $i = 0 To $f -1
$pm = $k[$h][$i][2]
If $pm <> 0 Then
$px = $k[$h][$i][0]
$py = $k[$h][$i][1]
$pk = $k[$h][$i][3]
$pj = $k[$h][$i][4]
$nx = $px * 2 - $pk
$ny = $py * 2 - $pj + $r
$k[$h][$i][3] = $px
$k[$h][$i][4] = $py
$k[$h][$i][0] = $nx
$k[$h][$i][1] = $ny
EndIf
Next
Next
For $h = 0 To 1
For $i = 0 To UBound($l) - 1
$tpm = $k[$l[$i][2]][$l[$i][3]][2]
$tpx = $k[$l[$i][2]][$l[$i][3]][0]
$tpy = $k[$l[$i][2]][$l[$i][3]][1]
$spm = $k[$l[$i][0]][$l[$i][1]][2]
$spx = $k[$l[$i][0]][$l[$i][1]][0]
$spy = $k[$l[$i][0]][$l[$i][1]][1]
$dx = $tpx - $spx
$dy = $tpy - $spy
$de = $dx * $dx + $dy * $dy
$di = ($de - 0.0064) / ((0.0064 + $de) * ($spm + $tpm))
If $spm <> 0 Then
$k[$l[$i][0]][$l[$i][1]][0] += $dx * $di
$k[$l[$i][0]][$l[$i][1]][1] += $dy * $di
EndIf
If $tpm <> 0 Then
$k[$l[$i][2]][$l[$i][3]][0] -= $dx * $di
$k[$l[$i][2]][$l[$i][3]][1] -= $dy * $di
EndIf
Next
Next
For $i = 0 To UBound($l) - 1
$spx = $k[$l[$i][0]][$l[$i][1]][0]
$spy = $k[$l[$i][0]][$l[$i][1]][1]
$tpx = $k[$l[$i][2]][$l[$i][3]][0]
$tpy = $k[$l[$i][2]][$l[$i][3]][1]
$x1 = $spx * $gg
$y1 = $spy * $jj
$x2 = $tpx * $gg
$y2 = $tpy * $jj
move($hGraphics, $x1, $y1)
linestep($hGraphics, $x2, $y2)
Next
clearbuffer($hBuffer)
EndFunc
Func Gravity()
If $r == 0 Then
$r = 0.00125
$o = 0
Else
$r = 0
$o = 1
EndIf
EndFunc
Have Fun!