Vor monaten habe ich angefangen einen Iconeditor zu basteln. Damals bin ich daran gescheitert mit Autoit eine "richtige" ico zu erstellen, jetzt kann ich C# und habe mir dafür eine DLL gemacht. Also jetzt habe ich es geschafft, leider hat er nicht sehr viele Farben ( 8 ). Die Scripts sollten selbsterklärend sein.
Dateien sind im Anhang
Script:
Spoiler anzeigen
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=ICONS\IconSetter.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIP.au3>
#include <Misc.au3>
#include <Color.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
Global $farbgui,$Uebernehmen,$Abbrechen,$Input1,$Input2,$Input3,$Input4
Global $farbgra,$farbbuffer,$farbbackgra,$farbimg
;17.4.2010
global $title="Iconsetter V1.5 by TheShadowAE"
#Region ### START Koda GUI section ### Form=D:\Progen\AutoIt\Meine\Forms\Iconsetter.kxf
$Form1 = GUICreate($title, 448, 321, 192, 124)
$Button1 = GUICtrlCreateButton("Laden", 332, 8, 97, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Speichern", 332, 43, 97, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Speichern als", 332, 78, 97, 25, $WS_GROUP)
$Button5 = GUICtrlCreateButton("Farbpalette", 332, 113, 97, 25, $WS_GROUP)
$Button6 = GUICtrlCreateButton("Bild leeren", 332, 148, 97, 25, $WS_GROUP)
$Button7 = GUICtrlCreateButton("Hintergrund", 332, 183, 97, 25, $WS_GROUP)
$Button8 = GUICtrlCreateButton("Icon Extrahieren", 332, 218, 97, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Farbe von Bild", 332, 253, 97, 25, $WS_GROUP)
$Button9 = GUICtrlCreateButton("Feld füllen", 332, 288, 97, 25, $WS_GROUP)
$Button10= GUICtrlCreateButton("<->",430,288,20,25,$WS_GROUP)
GUISetState(@SW_SHOW)
$Form2=guicreate("Saver",32,32)
#EndRegion ### END Koda GUI section ###
_GDIPlus_Startup()
FarbGUI("Farbpalette",$Form1)
Global $hg="0xFFFFFFFF"
Global $brush=_GDIPlus_BrushCreateSolid(0xFF000000)
global $gra=_GDIPlus_GraphicsCreateFromHWND($Form1)
global $buffer=_GDIPlus_BitmapCreateFromGraphics(320,320,$gra)
global $backgra=_GDIPlus_ImageGetGraphicsContext($buffer)
global $file=""
global $activepen
Dim $feld[32][32]
global $gra2=_GDIPlus_GraphicsCreateFromHWND($Form2)
global $buffer2=_GDIPlus_BitmapCreateFromGraphics(32,32,$gra2)
global $backgra2=_GDIPlus_ImageGetGraphicsContext($buffer2)
Global $change=0
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE,"ende",$Form1)
guictrlsetonevent($Button1,"load")
guictrlsetonevent($Button2,"save")
guictrlsetonevent($Button3,"saveas")
guictrlsetonevent($Button5,"palette")
guictrlsetonevent($Button6,"clean")
guictrlsetonevent($Button7,"hg")
guictrlsetonevent($Button8,"Extract")
guictrlsetonevent($Button4,"colorfi")
guictrlsetonevent($Button9,"fillfeld")
guictrlsetonevent($Button10,"change")
start()
While not _IsPressed("1B")
If xmouse()>=0 and xmouse()<=320 and ymouse()>=0 and ymouse()<=320 Then
if _ispressed("1") Then
$feld[Floor((xmouse())/10.01)][Floor((ymouse())/10.01)]=$activepen
EndIf
if _ispressed("2") Then
$feld[Floor((xmouse())/10.01)][Floor((ymouse())/10.01)]="0xFFFFFFFF"
EndIf
EndIf
if WinActive($title)=0 Then winwaitactive($title)
_WinAPI_RedrawWindow($Form1, "", "", $RDW_UPDATENOW + $RDW_FRAME)
_GDIPlus_GraphicsClear($backgra,0xFFFFFFFF)
for $x=0 to 31
for $y=0 to 31
if $feld[$x][$y]<>"0xFFFFFFFF" then
_GDIPlus_BrushSetSolidColor($brush,$feld[$x][$y])
_GDIPlus_GraphicsFillRect($backgra,$x*10,$y*10,10,10,$brush)
EndIf
Next
Next
_GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,320,320)
sleep(10)
WEnd
Func ende()
FarbGUIEnde()
_GDIPlus_BrushDispose($brush)
_GDIPlus_GraphicsDispose($gra)
_GDIPlus_BitmapDispose($buffer)
_GDIPlus_GraphicsDispose($backgra)
_GDIPlus_GraphicsDispose($gra2)
_GDIPlus_BitmapDispose($buffer2)
_GDIPlus_GraphicsDispose($backgra2)
_GDIPlus_Shutdown()
Exit
EndFunc
func start()
_GDIPlus_GraphicsClear($backgra,0xFFFFFFFF)
_GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,320,320)
$activepen="0xFF000000"
clean()
EndFunc
Func change()
If $change=0 Then
$change=1
GUICtrlSetData($Button9,"Farbe ersetzen")
Else
$change=0
GUICtrlSetData($Button9,"Feld füllen")
EndIf
EndFunc
Func fillfeld()
GUISetCursor(14,1,$Form1)
Local $ersetzen=""
Local $cx,$cy
while 1
If xmouse()>=0 and xmouse()<=320 and ymouse()>=0 and ymouse()<=320 Then
if _ispressed("1") Then
$cx=Floor((xmouse())/10.01)
$cy=Floor((ymouse())/10.01)
$ersetzen=$feld[$cx][$cy]
ExitLoop
EndIf
if _ispressed("2") Then ExitLoop
EndIf
Sleep(10)
WEnd
GUISetCursor(2,0,$Form1)
If $ersetzen="" Then Return
Local $durch=$activepen
If $change=0 Then
Local $pathblock[32][32]
For $x=0 To 31
For $y=0 To 31
If $feld[$x][$y]=$ersetzen Then
$pathblock[$x][$y]=0
Else
$pathblock[$x][$y]=1
EndIf
Next
Next
Local $p1[2],$p2[2]=[$cx,$cy]
For $x=0 to 31
For $y=0 to 31
$p1[0]=$x
$p1[1]=$y
If _isPath($pathblock,$p1,$p2,1000,1) Then $feld[$x][$y]=$durch
_WinAPI_RedrawWindow($Form1, "", "", $RDW_UPDATENOW + $RDW_FRAME)
_GDIPlus_GraphicsClear($backgra,0xFFFFFFFF)
For $x2=0 to 31
For $y2=0 to 31
if $feld[$x2][$y2]<>"0xFFFFFFFF" then
_GDIPlus_BrushSetSolidColor($brush,$feld[$x2][$y2])
_GDIPlus_GraphicsFillRect($backgra,$x2*10,$y2*10,10,10,$brush)
EndIf
Next
Next
_GDIPlus_BrushSetSolidColor($brush,$durch)
_GDIPlus_GraphicsFillRect($backgra,$x*10,$y*10,10,10,$brush)
_GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,320,320)
Next
Next
Else
For $x=0 to 31
For $y=0 to 31
If $feld[$x][$y]=$ersetzen Then $feld[$x][$y]=$durch
Next
Next
EndIf
EndFunc
Func colorfi()
GUISetCursor(14,1,$Form1)
while 1
If xmouse()>=0 and xmouse()<=320 and ymouse()>=0 and ymouse()<=320 Then
if _ispressed("1") Then
$activepen=$feld[Floor((xmouse())/10.01)][Floor((ymouse())/10.01)]
ExitLoop
EndIf
if _ispressed("2") Then ExitLoop
EndIf
Sleep(10)
WEnd
GUISetCursor(2,0,$Form1)
EndFunc
Func hg()
If $hg="0xFF000000" Then
$hg="0xFFFFFFFF"
Else
$hg="0xFF000000"
EndIf
clean()
EndFunc
func load()
$temp=FileOpenDialog("Öffnen","","Icons (*.ico)",3)
If $temp="" Then Return
$file=$temp
$ret=realload()
$tmp=$file
$file=@TempDir&"\tmp.ico"
save()
realload()
$file=$tmp
FileDelete(@TempDir&"\tmp.ico")
EndFunc
Func realload()
$hicon=_ExtractIcon($file)
$icon=_GDIPlus_BitmapCreateFromHICON($hicon)
_WinAPI_DestroyIcon($hicon)
$ix=_GDIPlus_ImageGetWidth($icon)
$iy=_GDIPlus_ImageGetHeight($icon)
Local $check=32
If $ix<$check Then
;~ MsgBox(48,"Fehler","Das Bild ist zu klein")
$file=""
_GDIPlus_BitmapDispose($icon)
Return -1
EndIf
If $iy<$check Then
;~ MsgBox(48,"Fehler","Das Bild ist zu klein")
$file=""
_GDIPlus_BitmapDispose($icon)
Return -1
EndIf
$BitmapData=_GDIPlus_BitmapLockBits($icon,0,0,32,32)
Local $Stride = DllStructGetData($BitmapData, "Stride")
Local $Width = DllStructGetData($BitmapData, "Width")
Local $Height = DllStructGetData($BitmapData, "Height")
Local $Scan0 = DllStructGetData($BitmapData, "Scan0")
Local $PixelData, $Color
For $row = 0 To 31
For $col = 0 To 31
$PixelData = DllStructCreate("dword", $Scan0 + ($row * $Stride) + ($col * 4))
$Color = DllStructGetData($PixelData, 1)
$feld[$row][$col]="0xFF"&Hex($Color)
Next
Next
_GDIPlus_BitmapUnlockBits($icon,$BitmapData)
_GDIPlus_BitmapDispose($icon)
EndFunc
func save()
$mybuff=drawtobuffer()
if $file<>"" Then
_GDIPlus_BitmapSaveIcon($mybuff,$file)
Else
$temp=FileSaveDialog("Speichern unter...", @ScriptDir, "Icons (*.ico)",16,"MyIcon.ico")
If $temp="" Then Return
$file=$temp
_GDIPlus_BitmapSaveIcon($mybuff,$file)
EndIf
_GDIPlus_ImageDispose($mybuff)
EndFunc
func saveas()
$mybuff=drawtobuffer()
$temp=FileSaveDialog("Speichern unter...", @ScriptDir, "Icons (*.ico)",16,"MyIcon.ico")
If $temp="" Then Return
$file=$temp
_GDIPlus_BitmapSaveIcon($mybuff,$file)
_GDIPlus_ImageDispose($mybuff)
EndFunc
func xmouse($tit="")
If $tit=""Then $tit=$title
$pos=MouseGetPos()
$win=WinGetPos($tit)
$x=$pos[0]-$win[0]-3
return $x
EndFunc
func ymouse($tit="")
If $tit=""Then $tit=$title
$pos=MouseGetPos()
$win=WinGetPos($tit)
$y=$pos[1]-$win[1]-28
return $y
EndFunc
func palette()
GUISetState(@SW_DISABLE,$Form1)
Local $tmp=Farbauswahl($activepen,1)
If $tmp="" Then
GUISetState(@SW_ENABLE,$Form1)
WinActivate($Form1)
Return
EndIf
$activepen=$tmp
GUISetState(@SW_ENABLE,$Form1)
WinActivate($Form1)
EndFunc
Func FarbGUI($titel="Farbauswahl",$parent=Default)
$farbgui=GUICreate($titel,300,200,Default,Default,Default,$WS_EX_TOOLWINDOW,$parent)
$Abbrechen = GUICtrlCreateButton("Abbrechen", 184, 168, 113, 25)
$Input1=GUICtrlCreateInput("00", 192, 8, 97, 21)
$Input2=GUICtrlCreateInput("00", 192, 40, 97, 21)
$Input3=GUICtrlCreateInput("00", 192, 72, 97, 21)
$Uebernehmen = GUICtrlCreateButton("Übernehmen", 184, 136, 113, 25)
$Input4=GUICtrlCreateInput("", 192, 104, 97, 21, $ES_READONLY)
GUICtrlSetBkColor($Input4,"0x"&Hex(GUICtrlRead($Input1),2)&Hex(GUICtrlRead($Input2),2)&Hex(GUICtrlRead($Input3),2))
$Label1 = GUICtrlCreateLabel("R:", 168, 8, 20, 17)
$Label2 = GUICtrlCreateLabel("G:", 168, 40, 20, 17)
$Label3 = GUICtrlCreateLabel("B:", 168, 72, 20, 17)
$Label4 = GUICtrlCreateLabel("=", 168, 104, 20, 17)
FileInstall(".\Bilder\Farben.jpg",@ScriptDir&"\Farben.jpg")
$farbgra=_GDIPlus_GraphicsCreateFromHWND($farbgui)
$farbbuffer=_GDIPlus_BitmapCreateFromGraphics(161,200,$farbgra)
$farbbackgra=_GDIPlus_ImageGetGraphicsContext($farbbuffer)
_GDIPlus_GraphicsSetSmoothingMode($farbbackgra,2)
$farbimg=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\Farben.jpg")
GUISetState(@SW_HIDE,$farbgui)
Return 1
EndFunc
Func Farbauswahl($farbe="0xFF000000",$isonevent=0)
Opt("GuiOnEventMode",0)
GUICtrlSetData($Input1,Dec(StringMid($farbe,5,2)))
GUICtrlSetData($Input2,Dec(StringMid($farbe,7,2)))
GUICtrlSetData($Input3,Dec(StringRight($farbe,2)))
Local $timer,$skill=0
Local $BitmapData,$Stride,$Width,$Height,$Scan0
Local $pos[2]
$timer=TimerInit()
_GDIPlus_GraphicsDrawImageRect($farbbackgra,$farbimg,0,0,161,200)
GUISetState(@SW_SHOW,$farbgui)
While 1
$msg=GUIGetMsg(1)
If $msg[1]=$farbgui Then
Switch $msg[0]
Case $GUI_EVENT_CLOSE,$Abbrechen
GUISetState(@SW_HIDE,$farbgui)
If $isonevent Then Opt("GuiOnEventMode",1)
Return ""
Case $Uebernehmen
GUISetState(@SW_HIDE,$farbgui)
If $isonevent Then Opt("GuiOnEventMode",1)
Return "0xFF"&Hex(GUICtrlRead($Input1),2)&Hex(GUICtrlRead($Input2),2)&Hex(GUICtrlRead($Input3),2)
EndSwitch
EndIf
$pos[0]=xmouse($farbgui)
$pos[1]=ymouse($farbgui)
If $pos[0]>=0 And $pos[0]<=161 And $pos[1]>=0 And $pos[1]<=200 And _IsPressed("1") Then
$color=_gdiplus_Bitmapgetpixel($farbbuffer,$pos[0],$pos[1])
$color = StringTrimLeft(Hex($color),2)
GUICtrlSetData($Input1,Dec(StringLeft($color,2)))
GUICtrlSetData($Input2,Dec(StringMid($color,3,2)))
GUICtrlSetData($Input3,Dec(StringRight($color,2)))
EndIf
If TimerDiff($timer)-$skill>=500 Then
GUICtrlSetBkColor($Input4,"0x"&Hex(GUICtrlRead($Input1),2)&Hex(GUICtrlRead($Input2),2)&Hex(GUICtrlRead($Input3),2))
GUICtrlSetData($Input4,Hex(GUICtrlRead($Input1),2)&Hex(GUICtrlRead($Input2),2)&Hex(GUICtrlRead($Input3),2))
$skill=TimerDiff($timer)
EndIf
_WinAPI_RedrawWindow($farbgui, "", "", $RDW_UPDATENOW + $RDW_FRAME)
_GDIPlus_GraphicsDrawImageRect($farbgra,$farbbuffer,0,0,161,200)
Sleep(10)
WEnd
EndFunc
Func FarbGUIEnde()
_GDIPlus_GraphicsDispose($farbgra)
_GDIPlus_BitmapDispose($farbbuffer)
_GDIPlus_GraphicsDispose($farbbackgra)
_GDIPlus_ImageDispose($farbimg)
GUIDelete($farbgui)
FileDelete(@ScriptDir&"\Farben.jpg")
Return 1
EndFunc
func drawtobuffer()
for $x=0 to 31
for $y=0 to 31
_GDIPlus_BrushSetSolidColor($brush,$feld[$x][$y])
_GDIPlus_GraphicsFillRect($backgra2,$x,$y,1,1,$brush)
Next
Next
_GDIPlus_GraphicsDrawImageRect($gra2,$buffer2,0,0,32,32)
$mybuff=_GDIPlus_BitmapCloneArea($buffer2,0,0,32,32)
return $mybuff
EndFunc
func clean()
for $x=0 to 31
for $y=0 to 31
$feld[$x][$y]=$hg
Next
Next
EndFunc
Func _BmpToIco($datei,$ndatei="")
;Author: TheShadowAE
If Not StringInStr($datei,".") Then $datei&=".bmp"
If StringRight($datei,3)="ico" Then $datei=StringTrimRight($datei,3)&"bmp"
If StringRight($datei,1)="." Then $datei&="bmp"
If Not FileExists($datei) Then Return SetError(1,0,-1)
If @AutoItX64 Then
If Not FileExists(@ScriptDir&"\bmptoicox64.dll") Then FileInstall("bmptoicox64.dll",@ScriptDir&"\bmptoicox64.dll")
DllCall("bmptoicox64.dll","none","Convert","str",$datei,"str",$ndatei)
Else
If Not FileExists(@ScriptDir&"\bmptoicox86.dll") Then FileInstall("bmptoicox86.dll",@ScriptDir&"\bmptoicox86.dll")
DllCall("bmptoicox86.dll","none","Convert","str",$datei,"str",$ndatei)
EndIf
If @error>0 Then Return SetError(1,1,0)
Return 1
EndFunc
Func _GDIPlus_BitmapSaveIcon($img,$datei)
;Author: TheShadowAE
If Not StringInStr($datei,".") Then $datei&=".bmp"
If StringRight($datei,3)="ico" Then $datei=StringTrimRight($datei,3)&"bmp"
If StringRight($datei,1)="." Then $datei&="bmp"
If $img=0 Then Return SetError(1,0,-1)
_GDIPlus_ImageSaveToFileEx($img,$datei,_GDIPlus_EncodersGetCLSID("BMP"))
$ret=_BmpToIco($datei)
If $ret=0 Then Return SetError(1,1,0)
FileDelete($datei)
Return 1
EndFunc
Func _ExtractIcon($file,$index=0,$mode=1)
;Author: TheShadowAE
Local $icon=DllStructCreate("ptr")
Local $picon=DllStructGetPtr($icon,1)
If $mode=1 Then
_WinAPI_ExtractIconEx($file,$index,$picon,0,1)
Else
_WinAPI_ExtractIconEx($file,$index,0,$picon,1)
EndIf
Local $hicon=DllStructGetData($icon,1)
Return $hicon
EndFunc
;####### Extract Icon Extension ###########
Func Extract()
$HICON=_ExtractPickedIcon(0,"",1)
$datei=InputBox("Dateiname","Dateiname eingeben:")
If $datei="" Then
_WinAPI_DestroyIcon($HICON)
Return
EndIf
_GDIPlus_HICONSaveToFile($HICON,$datei) ;_GDIPlus_BitmapSaveIcon
_WinAPI_DestroyIcon($HICON)
EndFunc
Func _PickIcon($hwnd,$pfad="")
Local $ret=DllCall("shell32.dll","int","PickIconDlg","hwnd",$hwnd,"wstr",$pfad,"uint",999,"int*",0)
If @error Or $ret[0]=0 Then SetError(1,0,0)
Local $aResult[2] = [$ret[2], $ret[4]]
Return $aResult
EndFunc
Func _GDIPlus_HICONSaveToFile($icon,$datei)
If $icon=0 Then Return SetError(1,0,-1)
$img=_GDIPlus_BitmapCreateFromHICON($icon)
$ret=_GDIPlus_BitmapSaveIcon($img,$datei)
If $ret=0 Then Return SetError(1,1,0)
Return 1
EndFunc
Func _ExtractPickedIcon($hwnd=0,$res="",$mode=1) ;1=großes Icon, 0=kleines Icon
;Author: TheShadowAE
Local $picked=_PickIcon($hwnd,$res)
If @error Then Return SetError(1,0,0)
$hicon=_ExtractIcon($picked[0],$picked[1],$mode)
Return $hicon
EndFunc
;###### Ende Extension #####################
;###### Pathfinding Extension ##############
;-3 => Punkt außerhalb der Karte
;-2 => Timeout
;-1 => Arrayerror
; 0 => kein Weg
; 1 => Weg
Func _isPath($feld,$p1,$p2,$timeout=1000,$wand=1);Welche MS-TIMEOUT-ZAHL? -> 1000 / old 5000
;Author: TheShadowAE
If Not IsArray($feld) or Not IsArray($p1) Or Not IsArray($p2) Then Return SetError(1,0,-1) ;ob alles Arrays sind
If UBound($feld,0)<2 Then Return SetError(2,0,-1);ob $feld 2+ D ist (3D wird nur 2D benutzt)
Local $width=UBound($feld,1)-1
Local $height=UBound($feld,2)-1
If $p1[0]<0 or $p1[1]<0 Or $p1[0]>$width Or $p1[1]>$height Then Return -3;Punkte außerhalb Karte?
If $p2[0]<0 or $p2[1]<0 Or $p2[0]>$width Or $p2[1]>$height Then Return -3;Punkte außerhalb Karte?
If $feld[$p2[0]][$p2[1]]=$wand Or $feld[$p1[0]][$p1[1]]=$wand Then Return 0;Punkt ist Wand?
Local $now[3]=[$p1[0],$p1[1],(Abs(($p2[0]-$p1[0])+($p2[1]-$p1[1])))]
Local $old[3]=[$now[0],$now[1],$now[2]]
Local $weg[4][3]
Local $nweg=0
Local $timer=TimerInit()
If $now[0]=$p2[0] And $now[1]=$p2[1] Then Return 1;Sind beide Punkte gleich?
While 1
$isnull=1
For $x=0 to $width
For $y=0 to $height
If $feld[$x][$y]<>$wand Then
$isnull=0
ExitLoop 2
EndIf
Next
Next
If $isnull=1 Then Return 0 ;Ist alles Wand?
$endit=1
If $now[1]-1>=0 Then
If $feld[$now[0]][$now[1]-1]<>$wand Then $endit=0
EndIf
If $now[0]+1<=$width Then
If $feld[$now[0]+1][$now[1]]<>$wand Then $endit=0
EndIf
If $now[1]+1<=$height Then
If $feld[$now[0]][$now[1]+1]<>$wand Then $endit=0
EndIf
If $now[0]-1>=0 Then
If $feld[$now[0]-1][$now[1]]<>$wand Then $endit=0
EndIf
If $endit=1 Then
;~ ConsoleWrite("Debug-Ende"&@CRLF);Debug
Return 0
EndIf
$old[0]=$now[0]
$old[1]=$now[1]
$old[2]=$now[2]
$weg[0][0]=$now[0]
$weg[0][1]=$now[1]-1
$weg[0][2]=Abs(($p2[0]-$weg[0][0])+($p2[1]-$weg[0][1]))
If $weg[0][1]<>Abs($weg[0][1]) Then
$weg[0][2]=$width+$height+3
$weg[0][1]=0
EndIf
$weg[1][0]=$now[0]+1
$weg[1][1]=$now[1]
$weg[1][2]=Abs(($p2[0]-$weg[1][0])+($p2[1]-$weg[1][1]))
If $weg[1][0]>$width Then
$weg[1][2]=$width+$height+3
$weg[1][0]=$width
EndIf
$weg[2][0]=$now[0]
$weg[2][1]=$now[1]+1
$weg[2][2]=Abs(($p2[0]-$weg[2][0])+($p2[1]-$weg[2][1]))
If $weg[2][1]>$height Then
$weg[2][2]=$width+$height+3
$weg[2][1]=$height
EndIf
$weg[3][0]=$now[0]-1
$weg[3][1]=$now[1]
$weg[3][2]=Abs(($p2[0]-$weg[3][0])+($p2[1]-$weg[3][1]))
If $weg[3][0]<>Abs($weg[3][0]) Then
$weg[3][2]=$width+$height+3
$weg[3][0]=0
EndIf
For $x=0 to 3
If $feld[$weg[$x][0]][$weg[$x][1]]=$wand Then $weg[$x][2]=$width+$height+3
Next
If $weg[0][2]<=$weg[1][2] Then ;'<=' da es egal ist wenn der Weg gleich lang ist
$nweg=0
Else
$nweg=1
EndIf
If $weg[$nweg][2]<=$weg[2][2] Then
$nweg=$nweg
Else
$nweg=2
EndIf
If $weg[$nweg][2]<=$weg[3][2] Then
$nweg=$nweg
Else
$nweg=3
EndIf
If $weg[$nweg][2]>$now[2] Then
$feld[$now[0]][$now[1]]=$wand
$now[0]=$old[0]
$now[1]=$old[1]
$now[2]=$old[2]
EndIf
If $weg[$nweg][2]<>$width+$height+3 Then
$now[0]=$weg[$nweg][0]
$now[1]=$weg[$nweg][1]
$now[2]=$weg[$nweg][2]
EndIf
;~ ConsoleWrite("Debug: "&$now[0]&" "&$now[1]&" "&$now[2]&@CRLF);Debug
;~ ConsoleWrite("Feld: "&$feld[0][0]&" "&$feld[1][0]&" "&$feld[2][0]&@CRLF);Debug für das Beispiel
;~ ConsoleWrite("Feld: "&$feld[0][1]&" "&$feld[1][1]&" "&$feld[2][1]&@CRLF);Debug für das Beispiel
;~ ConsoleWrite("Feld: "&$feld[0][2]&" "&$feld[1][2]&" "&$feld[2][2]&@CRLF);Debug für das Beispiel
If $now[0]=$p2[0] And $now[1]=$p2[1] Then Return 1 ;Am Ziel?
If TimerDiff($timer)>=$timeout Then Return -2 ;Timeout?
WEnd
EndFunc
;###### Ende Extension ################
Screenshot:
autoit.de/wcf/attachment/9295/
PS:
Die Palette ist auch nicht schön
EDIT:
Bug berichtig [DL1]
EDIT:
Update: Extractor in den Iconeditor reingebaut [DL5]
EDIT:
Größeres Update:
-Alle Farben auswählbar
-Richtige Farbpalette
-paar Bugs entfernt [DL5]
EDIT:
Jetzt kann man eine Farbe vom Bild auswählen [DL3]
In Planung: Flächen ausfüllen
EDIT:
Flächen ausfüllen ist es noch nicht, aber Farben ersetzen, also wieder Update [DL19]
EDIT:
-Flächen ausfüllen klappt, aber leider brauch das sehr lange, bitte um Vorschläge es zu verschnellern
-Bei der Palette funktioniert das Farbeauswählen jetzt richtig
-ich weiß nicht warum, aber beim laden ist das Bild plötzlich gedreht - wieder nicht mehr
Neuer Screenshot oben
-Man sieht wie sich die Fläche füllt
-Man kann zwischen Farbe ersetzen und Fläche füllen auswählen