5月162019
au3 gdi旋轉的文本-轉自德語論壇
;Coded by UEZ v0.40 build 2019-03-30 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> _GDIPlus_Startup() Global Const $iW = 600, $iH = 600 Global Const $hGUI = GUICreate("GDI+ Spiral Text", $iW, $iH) GUISetBkColor(0x606E8C) GUISetState() Global Const $hDC = _WinAPI_GetDC($hGUI) Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Global Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Global Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, 4) _GDIPlus_GraphicsClear($hCanvas, 0xFF606E8C) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, 4) _GDIPlus_GraphicsSetInterpolationMode($hCanvas, 7) _GDIPlus_GraphicsSetCompositingQuality($hCanvas, 2) ;~ _GDIPSpiralText(" AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.") _GDIPSpiralText(' AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!..............') _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) _GDIPlus_Shutdown() GUIDelete() Exit Func _GDIPSpiralText($sText) Local Const $fPi = ACos(-1), $fRad = ACos(-1) / 180, $fDeg = 180 / ACos(-1) Local $aText = StringSplit(StringReverse($sText), "", 2), $i, $fCx = $iW / 2, $fCy = $iH / 2, $fDegree, $iLen = UBound($aText) Local $tCoord = DllStructCreate("float x[" & $iLen & "];float y[" & $iLen & "];ptr img[" & $iLen & "];ptr gfx[" & $iLen & "]") Local $fSize = $iLen / Sqrt(($iW * $iW) + ($iH * $iH)) * 512, $fSize2 = $fSize * 2 Local $mwx, $mwy, $fFontSize, $f1, $f2, $c1 = $fSize / 2, $c2 = $fSize2 / 2, $fRadius = Sqrt(($iW * $iW) / 10 + ($iH * $iH) / 10) Local $iDX = -$fSize / 2, $iDY = $iDX Local $hDLL = DllOpen("user32.dll"), $bESC = False, $c3, $c4 = $iLen / 6, $c5 = 0.85 * Sqrt(($iW * $iW) / 2 + ($iH * $iH) / 2) / 2 #Region GDI+ For $i = 0 To $iLen - 1 $tCoord.img($i + 1) = _GDIPlus_BitmapCreateFromScan0($fSize, $fSize) $tCoord.gfx($i + 1) = _GDIPlus_ImageGetGraphicsContext($tCoord.img($i + 1)) _GDIPlus_GraphicsSetSmoothingMode($tCoord.gfx($i + 1), 6) _GDIPlus_GraphicsSetTextRenderingHint($tCoord.gfx($i + 1), 4) _GDIPlus_GraphicsSetPixelOffsetMode($tCoord.gfx($i + 1), 4) Next Local Const $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddEllipse($hPath, 4, 4, $iW - 9, $iH - 9) $tRECTF = _GDIPlus_RectFCreate(0, 0, $fSize, $fSize / 2) Local Const $hBrush = _GDIPlus_LineBrushCreateFromRectWithAngle($tRECTF, 0xFF101030, 0xFF3030E0, 45, 0, 1), _ $hFormat = _GDIPlus_StringFormatCreate(), _ $hFamily = _GDIPlus_FontFamilyCreate("Consolas"), _ $hBrush_c = _GDIPlus_BrushCreateSolid(0xFF000000), _ $hPen = _GDIPlus_PenCreate(0x18101010), $hPen2 = _GDIPlus_PenCreate(0x30101010, 8), $hBrush2 = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_LineBrushSetSigmaBlend($hBrush, 0.9, 0.95) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local Const $hBitmap_Bg = _GDIPlus_BitmapCreateFromScan0($iW, $iH), _ $hGfx_Bg = _GDIPlus_ImageGetGraphicsContext($hBitmap_Bg) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Bg, 6) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx_Bg, 4) _GDIPlus_PathBrushSetCenterColor($hBrush2, 0xFFC0C0C0) _GDIPlus_PathBrushSetCenterPoint($hBrush2, $fCx, $fCy) _GDIPlus_PathBrushSetSurroundColor($hBrush2, 0xFFFFFFFF) _GDIPlus_PathBrushSetGammaCorrection($hBrush2, True) _GDIPlus_GraphicsFillEllipse($hGfx_Bg, 4, 4, $iW - 9, $iH - 9, $hBrush2) _GDIPlus_GraphicsDrawEllipse($hGfx_Bg, 4, 4, $iW - 9, $iH - 9, $hPen2) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH), _ $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 6) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) Local Const $hBitmap_Cursor = _GDIPlus_BitmapCreateFromScan0($fSize2, $fSize2), _ $hGfx_Cursor = _GDIPlus_ImageGetGraphicsContext($hBitmap_Cursor) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Cursor, 6) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx_Cursor, 4) Local Const $hMatrix = _GDIPlus_MatrixCreate(), $hMatrix2 = _GDIPlus_MatrixCreate() _GDIPlus_PenSetStartCap($hPen, 0x14) #EndRegion GDI+ For $i = $iLen - 1 To 0 Step -1 _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap_Bg, 0, 0, $iW, $iH) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap, 0, 0, $iW, $iH) $fDegree = $iLen / $c4 * $i ;space between chars $tCoord.x($i + 1) = $fCx + Sin($fDegree * $fRad) * $fRadius $tCoord.y($i + 1) = $fCy + Cos($fDegree * $fRad) * $fRadius $fRadius -= $c5 / $iLen $fFontSize = $fRadius / 7 ;calculate the angle of each char $mwx = $tCoord.x($i + 1) - $fCx $mwy = $fCy - $tCoord.y($i + 1) $c3 = ($mwx + Sqrt($mwx * $mwx + $mwy * $mwy)) $fAngle = 2 * -ATan($mwy / $c3) * $fDeg If Not $c3 Then If $mwx < 0 Then $fAngle = -180 Else $fAngle = 180 EndIf EndIf $f1 = $iDX + $c1 $f2 = $iDY + $c1 If $i < $iLen - 1 Then _GDIPlus_PenSetWidth($hPen, $fFontSize / 8) DllCall($__g_hGDIPDll, "int", "GdipDrawLine", "handle", $hCanvas, "handle", $hPen, "float", $tCoord.x($i + 1) + $f1, "float", $tCoord.y($i + 1) + $f2, _ "float", $tCoord.x($i + 2) + $f1, "float", $tCoord.y($i + 2) + $f2) DllCall($__g_hGDIPDll, "int", "GdipDrawLine", "handle", $hGfx, "handle", $hPen, "float", $tCoord.x($i + 1) + $f1, "float", $tCoord.y($i + 1) + $f2, _ "float", $tCoord.x($i + 2) + $f1, "float", $tCoord.y($i + 2) + $f2) EndIf ;rotated each char according to angle _GDIPlus_MatrixSetElements($hMatrix) ;reset matrix _GDIPlus_MatrixTranslate($hMatrix, $c1, $c1) _GDIPlus_MatrixRotate($hMatrix, 90 + $fAngle) _GDIPlus_MatrixTranslate($hMatrix, -$c1, -$c1) _GDIPlus_GraphicsSetTransform($tCoord.gfx($i + 1), $hMatrix) ;rotate cursor _GDIPlus_MatrixSetElements($hMatrix2) ;reset matrix _GDIPlus_MatrixTranslate($hMatrix2, $c2, $c2) _GDIPlus_MatrixRotate($hMatrix2, 90 + $fAngle) _GDIPlus_MatrixTranslate($hMatrix2, -$c2, -$c2) _GDIPlus_GraphicsSetTransform($hGfx_Cursor, $hMatrix2) _GDIPlus_GraphicsClear($hGfx_Cursor, 0x00000000) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGfx_Cursor, "handle", $hBrush_c, _ "float", $fSize * 0.475, "float", $fSize * 0.2, _ "float", $fSize * 1.075, "float", $fSize * 1.575) $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize) _GDIPlus_GraphicsDrawStringEx($tCoord.gfx($i + 1), $aText[$i], $hFont, _GDIPlus_RectFCreate(0, 0, $fSize, $fSize), $hFormat, $hBrush) _GDIPlus_GraphicsDrawImageRect($hCanvas, $tCoord.img($i + 1), $iDX + $tCoord.x($i + 1), $iDY + $tCoord.y($i + 1), $fSize, $fSize) _GDIPlus_GraphicsDrawImageRect($hGfx, $tCoord.img($i + 1), $iDX + $tCoord.x($i + 1), $iDY + $tCoord.y($i + 1), $fSize, $fSize) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap_Cursor, $tCoord.x($i + 1) + $f1 - $fFontSize, $tCoord.y($i + 1) + $f2 - $fFontSize, $fFontSize * 2, $fFontSize * 2) _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI _GDIPlus_FontDispose($hFont) ;~ _GDIPlus_GraphicsDrawLine($hGfx, $iW / 2, 0, $iW / 2, $iH) ;~ _GDIPlus_GraphicsDrawLine($hGfx, 0, $iH / 2, $iW, $iH / 2) _GDIPlus_GraphicsClear($hCanvas, 0xFF606E8C) If Not $bESC Then Sleep(30) If _IsPressed("20", $hDLL) Then ;speed up $bESC = True EndIf Next DllClose($hDLL) _GDIPlus_MatrixSetElements($hMatrix) _GDIPlus_PenSetWidth($hPen, 8) Do _GDIPlus_MatrixTranslate($hMatrix, $fCx, $fCy) _GDIPlus_MatrixRotate($hMatrix, -0.1) _GDIPlus_MatrixTranslate($hMatrix, -$fCx, -$fCy) _GDIPlus_GraphicsSetTransform($hCanvas, $hMatrix) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap_Bg, 0, 0, $iW, $iH) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap, 0, 0, $iW, $iH) _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) _GDIPlus_GraphicsClear($hCanvas, 0xFF606E8C) Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_PathDispose($hPath) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_BrushDispose($hBrush_c) _GDIPlus_BrushDispose($hBrush) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_MatrixDispose($hMatrix2) For $i = 0 To $iLen - 1 _GDIPlus_GraphicsDispose($tCoord.gfx($i + 1)) _GDIPlus_BitmapDispose($tCoord.img($i + 1)) Next _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Cursor) _GDIPlus_BitmapDispose($hBitmap_Cursor) _GDIPlus_GraphicsDispose($hGfx_Bg) _GDIPlus_BitmapDispose($hBitmap_Bg) EndFunc ;==>_GDIPSpiralText
發表評論
木有頭像就木JJ啦!還木有頭像嗎?點這里申請屬于你的個性Gravatar頭像吧!