Jump to content

DatMCEyeBall

Active Members
  • Posts

    682
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by DatMCEyeBall

  1. Well, a lot has changed since those versions, so you could say: 「Nah, it doesn't matter」.
  2. Is that a typo, or was it done on purpose?
  3. Danm javascript never load properly, fixed the code in my post.
  4. #include <File.au3> #include <GDIPlus.au3> #include <MsgBoxConstants.au3> Global Const $sInFolder = "In\" ; The folder where all your original .pngs are Global Const $sOutFolder = "Out\" ; The folder where the new .pngs will be stored ; Generate a list of all the png files in $sInFolder Global $asList = _FileListToArray($sInFolder, "*.png", 1, False) If @error Then Switch @error Case 1 _ErrMsgExit("Folder not found or invalid, " & $sInFolder, -11) Case 2 _ErrMsgExit("Invalid _FileListToArray() filter supplied", -12) Case 3 _ErrMsgExit("Invalid _FileListToArray() Flag", -13) Case 4 _ErrMsgExit("No files found in " & $sInFolder, -14) EndSwitch EndIf ; Crop the images _GDIPlus_Startup() ; I'm assuming that all the input files are different sizes and that the top left (0, 0) ; needs to be cropped into a 500 x 400 frame (NOTE: if the file is too small (under 500 x 400) then a blank space will occur) Global $hImage, $hNewImage, $hCtxt, $sErrorList = "" For $i = 1 To $asList[0] ; Loop through all files $hImage = _GDIPlus_ImageLoadFromFile($asList[$i]) ; Attempt to load file If @error Then _StringAppend($sErrorList, "Error loading file: """ & $asList[$i] & """ @extended = " & @extended) ContinueLoop ; Start the loop again since we can't use this image EndIf $hNewImage = _GDIPlus_BitmapCreateFromScan0(500, 400) ; Creata a blank 500 x 400 bitmap $hCtxt = _GDIPlus_ImageGetGraphicsContext($hNewImage) ; Get the GraphicsContext of an image (so we can write to it) ; _GDIPlus_GraphicsClear($hCtxt, 0xFF000000) ; Uncomment if you want the background to be a solid colour _GDIPlus_GraphicsDrawImageRectRect( _ $hCtxt, $hImage, _ 0, 0, 500, 400, _ ; Source image ($hImage) (X, Y, Width, Height) (ie. Take data from $hImage at XY 0, 0 with a width of 500 and height of 400) 0, 0, 500, 400, _ ; Destination image ($hCtxt -> $hNewImage) (ie. Write to $hNewImage at XY 0, 0 with a width of 500 and height of 400) ) ; Note: Keep the source image and destination image Width / Height the same to prevent resizing ; At this point $hNewImage contains the new data _GDIPlus_GraphicsDispose($hCtxt) ; We no longer need to write to it, so get rid of it _GDIPlus_ImageDispose($hImage) ; We no longer need to read from it, so get rid of it _GDIPlus_ImageSaveToFile($hNewImage, $sOutFolder & $asList[$i]) ; Write $hNewImage to the folder If @error Then _StringAppend($sErrorList, "Error saving file: """ & $sOutFolder & $asList[$i] & """ @extended = " & @extended) EndIf _GDIPlus_ImageDispose($hNewImage) ; Don't need it anymore Next If $sErrorList <> "" Then MsgBox($MB_OK + $MB_ICONWARNING, "Warning", "The following errors have occured:" & @CRLF & @CRLF & $sErrorList) EndIf _GDIPlus_Shutdown() Func _ErrMsgExit($sMsg, $iCode, $iLine = @ScriptLineNumber) If Not @Compiled Then $sMsg = "An error occured on line " & $iLine & ":" & @CRLF & @CRLF & $sMsg MsgBox($MB_OK + $MB_ICONERROR, "Critical error", $sMsg) Exit $iCode EndFunc ;==>_ErrMsgExit Func _StringAppend(ByRef $sString, $sAppend, $sDelim = @CRLF) #cs If $sString = "" Then $sString &= $sAppend Else $sString &= $sDelim & $sAppend EndIf #ce ; Same as above, but with the Ternary operator $sString &= (($sString = "") ? ("") : ($sDelim)) & $sAppend Return 1 EndFunc ;==>_StringAppend
  5. I'll have more up later today (some other examples that are not Jerome's). Even more when I convert the S3d UDF to C++
  6. "Wavy Thing" #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 25 Global $anPosX[$iNum] Global $nUnit, $nTheta, $nX, $nSzX, $nSzY Global $fClose = False Global $iW = 500, $iH = 300 Global $hGUI = GUICreate('"Wavy thing" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetBkColor(0) GUISetOnEvent(-3, "_Exit") $nUnit = ($iW - 50) / $iNum _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hBrush = _GDIPlus_BrushCreateSolid(0xFFFCD300) Global $hPen = _GDIPlus_PenCreate(0xFF777777, 1) Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xBE000000) For $i = 0 To $iNum - 1 $nSzX = _Map(Sin($nTheta + ($nTWOPI / $iNum) * $i), -1, 1, 5, 10) $nSzY = _Map(Sin($nTheta + ($nPI / $iNum) * $i), -1, 1, 30, $iH / 1.2) $nX = _Map(Sin($nTheta + ($nPI / $iNum / 2) * $i), -1, 1, $i * $nUnit, $iW / 2) _GDIPlus_GraphicsFillDrawRect($hGraphics, $nX + 25, _CenterPoint($nSzY, $iH), $nSzX, $nSzY, $hBrush, $hPen) Next $nTheta += 0.0523 _ModIfGreater($nTheta, $nTWOPI) EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _GDIPlus_GraphicsFillDrawRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush = 0, $hPen = 0) _GDIPlus_GraphicsFillRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush) _GDIPlus_GraphicsDrawRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $hPen) Return 1 EndFunc ;==>_GDIPlus_GraphicsFillDrawRect Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc ;==>_ModIfGreater Func _CenterPoint($iCur, $iTotal) Return $iTotal / 2 - $iCur / 2 EndFunc ;==>_CenterPoint
  7. "Lava Lamp" #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 125 Global $aiMaxSize[$iNum] Global $anOffset[$iNum] Global $nTheta, $nSz, $nX Global $aiPalette[] = [0x64F58F12, 0x640B9EE7, 0x644EA731, 0x64F4D910, 0x64F334E3] For $i = 0 To $iNum - 1 $aiMaxSize[$i] = Random(50, 120, 1) $anOffset[$i] = Random(0, $nTWOPI) Next Global $fClose = False Global $iW = 500, $iH = 500 Global $hGUI = GUICreate('"Lava Lamp" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hBrush = _GDIPlus_BrushCreateSolid() Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xFF202020) For $i = 0 To $iNum - 1 _GDIPlus_BrushSetSolidColor($hBrush, $aiPalette[Mod($i, 5)]) $nX = _Map(Sin($nTheta + $anOffset[$i]), -1, 1, 150, 350 - $aiMaxSize[$i]) _GDIPlus_GraphicsFillRect($hGraphics, $nX, $iH / $iNum * $i, $aiMaxSize[$i], 20, $hBrush) Next $nTheta += 0.0523 / 2 _ModIfGreater($nTheta, $nTWOPI) EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc ;==>_ModIfGreater
  8. "Trunk in space" #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iSz = 300, $iNum = 40 Global $nTheta, $nAngle, $nRad = 200 Global $fClose = False Global $iW = 500, $iH = 500 Global $hGUI = GUICreate('"Trunk in space" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 6, 2) Global $hBrush = _GDIPlus_BrushCreateSolid() Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF) $nAngle = 0 Local $nX, $nY, $nS, $nScal Local $iF For $i = 0 To $iNum - 1 $nX = $iW / 2 - $nRad / 2 + Cos($nAngle) * $nRad $nY = $iH / 2.5 + Sin($nAngle) * $nRad $nS = _Map(Sin($nTheta + $nTWOPI / $iNum * $i * 2), -1, 1, 1, 0.7) $nScal = 1 - 0.03 * $i $iF = Int(255 / $iNum * $i) _GDIPlus_BrushSetSolidColor($hBrush, "0xFF" & Hex(_WinAPI_ColorHLSToRGB($iF, 100, 160), 6)) _GDIPlus_GraphicsFillDrawEllipse($hGraphics, 0, $nY, $iSz * $nScal * $nS, $iSz * $nScal * $nS, $hBrush, $hPen) $nAngle -= $nPI / $iNum Next $nTheta += 0.0523 _ModIfGreater($nTheta, $nTWOPI) EndFunc ;==>_Draw Func _GDIPlus_GraphicsFillDrawEllipse($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush = 0, $hPen = 0) _GDIPlus_GraphicsFillEllipse($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush) _GDIPlus_GraphicsDrawEllipse($hGraphics, $nX, $nY, $nWidth, $nHeight, $hPen) Return 1 EndFunc ;==>_GDIPlus_GraphicsFillDrawEllipse Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc ;==>_ModIfGreater
  9. This is a great tool for improving scripts that rely on complex equations. Thanks, I might use it over compiling a .dll in some cases
  10. The next one I'm doing is Trunk in space
  11. I wrote this after seeing Jerome Herr's post on Tumblr and looking at the code here. A few Google searches later, I came up with these. #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 25 Global $nStep, $nSz, $nTheta $nStep = 20 Global $iMaxRad = ($iNum - 1) * $nStep Global $fClose = False Global $iW = $iMaxRad, $iH = $iMaxRad Global $hGUI = GUICreate('"Wave" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 3, 2) Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xFF000000) Local $nArcEnd, $nOffset, $nDrawOffset For $i = 0 To $iNum - 1 $nSz = $i * $nStep $nOffset = $nTWOPI / $iNum * $i $nDrawOffset = $iMaxRad / 2 - $nSz / 2 $nArcEnd = _Degree(_Map(Sin($nTheta + $nOffset), -1, 1, $nPI, $nTWOPI) - $nPI) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 0, $nArcEnd, $hPen) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 180, $nArcEnd, $hPen) Next $nTheta += 0.0523 If $nTheta > $nTWOPI Then $nTheta = Mod($nTheta, $nTWOPI) EndIf EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Playing with hue: #include <GDIPlus.au3> #include <Math.au3> #include <WinAPIGdi.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 25 Global $nStep, $nSz, $nTheta Global $iStHue = 0 $nStep = 20 Global $iMaxRad = ($iNum - 1) * $nStep Global $fClose = False Global $iW = $iMaxRad, $iH = $iMaxRad Global $hGUI = GUICreate('"Wave" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 3, 2) Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite("Draw: " & TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0x7F000000) Local $nArcEnd, $nOffset, $nDrawOffset For $i = 0 To $iNum - 1 $nSz = $i * $nStep $nOffset = $nTWOPI / $iNum * $i $nDrawOffset = $iMaxRad / 2 - $nSz / 2 $nArcEnd = _Degree(_Map(Sin($nTheta + $nOffset), -1, 1, $nPI, $nTWOPI) - $nPI) _GDIPlus_PenSetColor($hPen, "0xFF" & Hex(_WinAPI_ColorHLSToRGB($iStHue + $i, 120, 240), 6)) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 0, $nArcEnd, $hPen) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 180, $nArcEnd, $hPen) Next $nTheta += 0.0523 $iStHue += 0.5 _ModIfGreater($nTheta, $nTWOPI) _ModIfGreater($iStHue, 239) EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc >#6 - Trunk in space >#7 - Lava Lamp >#8 - Wavy Thing
  12. Let's wait for a dev to come along then.
  13. Melba23, User preferences and Seminko's too... I wonder what the Rube Goldberg solution would be.
  14. Melba23; Seminko, He can use the $CBS_DROPDOWNLIST style, no need for unnecessary checks.
  15. So AutoIt externally references it's structs by pointers, or does it convert the internal "handle" into a real one?
  16. Re-dim it to 1 element, set the first one to "", and resize it to the original size after? I see where you're going, and it would be easier to just redeclare it - but would it be considered a "good coding practice"?
  17. @czardas You can just assign the value of the array to 0 $avData = 0
  18. New update! See OP for download. I was thinking of using the DWM blur for the transparent areas on the widgets, that way the color changes with your DWM window colour.
  19. If you try searching on Youtube for "Microsoft Visual Studio 2012 C++ tutorial": http://www.youtube.com/watch?v=xoExJLVroZc
  20. Look at the @error set by DllCall (3) the documentation says that this means ""function" not found in the DLL file,".
  21. I'm adding this to the OP. What exactly is bothering you with MS VS C++? If you have a problem then Google it - that's what I do.
  22. Look at the first line of WaterSim.au3 (the Global Enum line). Check the UseBuffer1 flag in the params structure (forgot the Enum's name) if so use the HM (height map) #1 if not use #2 Add to the data (+=) at the specified location an amount (it's a height map used by the .dll so add a number like 512 or more - depends on what you prefer) The height map is a 1D array, I think the main .au3 file still has a _PixelIndexFromXY (or similar) function, use it to convert XY co-ordinates into the index of the array. Call the NewFrame function to draw and flatten the water. I can write you something special instead. If you want me to do so then please PM me. Mentor? C++ for dummies(link to .pdf) is what I used to learn it, VS is just there for convenience.
  23. I fixed it (compiled w static links) see the OP for download.
  24. I wrote this a while ago and only recently implemented shading. The current shading algorithm could use some improvements. Most of the source is based from here. The .dll source is also in the archive (made with Visual Studio 2012 Express). 2D Water simulation using a C++ dll.7z If you use a x64 bit OS then: EDIT: Added an example using a .gif file (split into frames).
×
×
  • Create New...