绿色风's Blog
专注AutoIT(Au3)
  • 首页
  • 流●年
  • 笔●记
    • 学习随记
    • 源码示例
  • 脚●本
    • UDF(收集)
    • 工作室UDF
    • 工具●教程
    • 教程之GDI
  • 作●品
  • 下●载
  • 情怀ExcelTip
5月162019

au3 gdi旋转的文本-转自德语论坛

作者:绿色风   发布:2019-5-16 3:23 Thursday   分类:源码示例   阅读:4471次   评论:2条  

QQ图片20190516112145.png

 


#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```
<br />
<p>
    &nbsp;
</p>
<p>
    &nbsp;
</p>




本文固定链接: http://www.jianyiit.com/post-310.html

blogger
该日志由 绿色风 于2019-5-16 3:23 Thursday发表在 源码示例 分类下。
版权所有:《绿色风's Blog》 → 《au3 gdi旋转的文本-转自德语论坛》;
除特别标注,本博客很多文章均为原创. 互联分享,尊重版权,转载请以链接形式标明本文地址;
本文标签:

扫描二维码,在手机上阅读
上一篇::实现对控件inputbox的禁止粘贴
下一篇:简单的动态密码设置

热门文章

相关文章

  • 笔记本电池电量显示
  • 窗体边缘阴影-示例
  • Au3取巧方式从窗口列表中获取本机登陆的QQ号码
  • AU3拼图游戏
  • 旋转动画AU3
评论列表 ↓
呦,果断人中龙凤! 金牛347      2019-07-10 00:44 @回复
風兄 , 記得我嗎?
論壇怎麼不能登入了?
绿色风      2019-07-10 17:25 @回复>
@金牛347:老大,MSN关后老找不到你的了。你的QQ也不用,
给我您的联系方式,我的E-mail: 79664738@qq.com
取消回复

发表评论

亲,头像对么?

95 + 49 =

提交中,请稍候……


木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!


    站点统计
    • 运行时间: 20254 天
    • 日志总数: 365 篇
    • 评论数量: 7225 条
    • 微语数量: 6 条
    • 附件总量: 388 件
  • 逝出的青春

  • 打赏"绿色风"



      扫码关注本站公众号 可搜本站内容

  • Autoit V3 脚本交流群

      常驻群1:905774875
      常驻群2:40672266


  • 链接

    • AU3中文论坛
    • Excel资料库
    • 完美者博客
    • 顺网小哥'S Blog
    • 猛牛哥的博客
    • 网吧系统下载
  • 分类

    • 流●年(66)
    • 笔●记(0)
    • 脚●本(0)
    • 作品(21)
    • 学习随记(51)
    • 源码示例(68)
    • UDF(收集)(26)
    • 工作室UDF(30)
    • 工具●教程(62)
    • 教程之GDI(24)
Copyright © 2013 绿色风's Blog. Powered by emlog. Theme by 射雕天龙. 鄂ICP备2021011689号-1 鄂公网安备42102302000078号 sitemap