找回密码
 加入
搜索
楼主: joint

[图形处理] 动态进度条,AU3能否绘制类似这样的实时动态图?

 火..   [复制链接]
发表于 2017-6-24 08:54:22 | 显示全部楼层
表示不会 进来学习
 楼主| 发表于 2017-6-24 09:09:14 | 显示全部楼层
概念上好像得先构造个可以添加控件的表格空间(表格数目最好还能根据数据情况自动增减),然后再做个可以根据不同数据和顺序产生形状、大小、颜色变化的控件,再然后,把该控件产生的图形按顺序实时绘制到相应的表格里。但是,对于崭新的新手来说,有点无从下手啊,请大神们多多指导。非常非常感谢。
 楼主| 发表于 2017-6-24 09:13:10 | 显示全部楼层
本帖最后由 joint 于 2017-6-24 09:19 编辑

前些天用pyqt5比葫芦画瓢绘制了个下面的表格,下来的事情就搞不定了。感觉比较难啊。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2017-6-25 10:16:30 | 显示全部楼层
看到一些有参考价值的帖子:
一、
GDI+绘制曲线图并自动更新
ashfinal 发表于 2012-5-28 19:05 [/quote]

二、
帮助文档里的进度条样例,其中进度条的参数可以设置为变量,这样嵌入到循环里就应该可以改变进度条的形状、大小和颜色了吧?
#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>

GUICreate("我的 GUI 之进度条",220,100, 100,200)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$button = GUICtrlCreateButton ("开始",75,70,70,20)
GUISetState ()

$wait = 20; 进度条没进一个单位就等20毫秒
$s = 0; 用于保存进度条的滑块位置
do
$msg = GUIGetMsg()
If $msg = $button Then
    GUICtrlSetData ($button,"暂停")
    For $i = $s To 100
                       
    If GUICtrlRead($progressbar1) = 50 Then Msgbox(0,"信息","已完成一半...", 1)
    $m = GUIGetMsg ()
   
    If $m = -3 Then ExitLoop
   
    If $m = $button Then
      GUICtrlSetData ($button,"继续")
      $s = $i;保存当前滑块位置到 $s
      ExitLoop
    Else
        $s=0
      GUICtrlSetData ($progressbar1,$i)
      GUICtrlSetData ($progressbar2,(100 - $i))
      Sleep($wait)
    EndIf
    Next
    if $i >100 then
;       ;s=0
        GUICtrlSetData ($button,"开始")
    endif
EndIf
until $msg = $GUI_EVENT_CLOSE
 楼主| 发表于 2017-6-25 10:20:41 | 显示全部楼层
在控件上绘制图形的参考帖子:
http://www.autoitx.com/forum.php ... hlight=%CD%BC%D0%CE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate('图片背景按钮例子')
$Button1 = GUICtrlCreateButton('按钮', 150, 270, 100, 25)
GUICtrlCreatePic(RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & "\Examples\GUI\msoobe.jpg", 0, 0, 400, 400, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
GUISetState()

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $Button1
                        MsgBox(0, 0, 'ok')
        EndSwitch
WEnd


http://www.autoitx.com/forum.php ... hlight=%CD%BC%D0%CE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
FileInstall("Black.she", @TempDir & "\Black.she", 1)
FileInstall("Skin.dll", @TempDir & "\Skin.dll", 1)
$skins = @TempDir & "\Black.she"
$dll = DllOpen(@TempDir & "\Skin.dll")
DllCall($dll, "int", "SkinH_AttachEx", "str", $skins, "str", "mhgd")
DllCall($dll, "int", "SkinH_SetAero", "int", 1)
$Form1 = GUICreate("平直度判断工具", 905, 585, @DesktopWidth / 2 - 452, @DesktopHeight / 2 - 292)
$ButtonDown = GUICtrlCreateButton("下一个", 257, 392, 65, 33)
$Graphic1 = GUICtrlCreateGraphic(384, 24, 500, 400)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, 500, 400)
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd


GDI+绘制曲线图并自动更新
http://www.autoitx.com/forum.php ... FC%D0%C2&page=1
发表于 2017-6-25 12:54:05 | 显示全部楼层
 楼主| 发表于 2017-6-29 17:33:28 | 显示全部楼层
回复  joint
lpxx 发表于 2017-6-25 12:54


谢谢。看了几个你的帖子,水平挺高,请多帮忙啊。谢谢。
 楼主| 发表于 2017-6-29 17:42:43 | 显示全部楼层
本帖最后由 joint 于 2017-7-4 16:55 编辑

昨天晚上翻老帖翻到2点多,发现了不少感觉很不错的帖子,做个记号,得好好学习。
不过,现在是基本上全看不懂,不知道怎样才能快速入手?有那位能先给个注释吗?我出点辛苦费:


請問如何讓 array 顯示在GUI裡面? 然後每秒更新一次arrayhttp://www.autoitx.com/forum.php ... &from=favorites

TAB内的ListView显示慢速原因http://www.autoitx.com/forum.php ... 2088&highlight=

GDI+绘制曲线图并自动更新http://www.autoitx.com/forum.php ... &from=favorites

在ListView上设置进度条http://www.autoitx.com/forum.php ... &from=favorites

画图UDF函数http://www.autoitx.com/forum.php ... &from=favorites

载入条http://www.autoitx.com/forum.php ... 7&highlight=GDI
 楼主| 发表于 2017-6-29 17:53:41 | 显示全部楼层
这些看起来很棒啊:

;coded by UEZ build 2014-03-04, idea taken from http://codepen.io/Fahrenheit/pen/Kbyxu
;AutoIt v3.3.9.21 or higher needed!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iW = 400, $iH = 150
Global Const $hGUI = GUICreate("Multi Color Loader", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()

Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 30, $s = 0, $t, $m = 0, $iPerc = 0
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

Do
 楼主| 发表于 2017-6-29 17:54:29 | 显示全部楼层
;coded by UEZ build 2014-04-28, idea taken from http://codepen.io/noahblon/pen/KwiFg
;AutoIt v3.3.9.21 or higher needed!

#include <Array.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iW = 600, $iH = 300
Global Const $hGUI = GUICreate("Carousel", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()

Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 10, $iPerc = 0
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

Do
        Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                        GUIRegisterMsg($WM_TIMER, "")
                        _WinAPI_DeleteObject($hHBmp_BG)
                        _GDIPlus_Shutdown()
                        GUIDelete()
                        Exit
        EndSwitch
Until False

Func PlayAnim()
        $hHBmp_BG = _GDIPlus_Carousel($iPerc, $iW, $iH)
        $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
        If $hB Then _WinAPI_DeleteObject($hB)
        _WinAPI_DeleteObject($hHBmp_BG)
        $iPerc += 0.2
        If $iPerc > 99.9 Then $iPerc = 0
EndFunc   ;==>PlayAnim


Func _GDIPlus_Carousel($fPerc, $iW, $iH, $bHBitmap = True)
        Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
        Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
        _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4 + (@OSBuild > 5999))
;~         _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 3)
        _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4)
        _GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF)

        Local Const $iUB = 4
        Local $aColors[$iUB][4] = [[0xD8F4B401, 0xE8CF9902], [0xD8E3746C, 0xE8C1645C], [0xD83A7BF9, 0xE8326AD4], [0xD8109D59, 0xE80E864C]]
        Local Const $fRadius = 50, $fMid = ($iW - $fRadius) / 2
        Local Const $hBrush = _GDIPlus_BrushCreateSolid(), $hPen = _GDIPlus_PenCreate(0x80000000)
        Local Const $hPath1 = _GDIPlus_PathCreate(), $hPath2 = _GDIPlus_PathCreate()
        Local $hRegion1, $hRegion2, $fPenSize, $i
        Local Static $fSpeed

        For $i = 0 To $iUB - 1
                $aColors[$i][2] = -Sin($fSpeed + $i * 1.570796) * 15                                ;z coordinate, 1.570796 = Pi/2 = 90?= 360?/ 4
                $aColors[$i][3] = $fMid + Cos($fSpeed + $i * 1.570796) * 80                        ;x coordinate
        Next
        _ArraySort($aColors, 0, 0, 0, 2) ;sort z-axis
        For $i = 0 To $iUB - 1
                $fPenSize = $aColors[$i][2] / 20 + 1.1
                _GDIPlus_PenSetWidth($hPen, $fPenSize)
                _GDIPlus_BrushSetSolidColor($hBrush, 0x80E0E0E0) ;shadow color
                _GDIPlus_GraphicsFillEllipse($hGfx, $aColors[$i][3], ($iH - $fRadius) / 2 + 10 + $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2], ($fRadius + $aColors[$i][2]) / 4, $hBrush)

                _GDIPlus_PathAddEllipse($hPath1, $aColors[$i][3], ($iH - $fRadius) / 2, $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2])
                _GDIPlus_PathAddEllipse($hPath2, $aColors[$i][3] + $fPenSize - 5 - $aColors[$i][2] / 10, ($iH - $fRadius) / 2 - $fPenSize - 5 - $aColors[$i][2] / 10, $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2])

                $hRegion1 = _GDIPlus_RegionCreateFromPath($hPath1)
                $hRegion2 = _GDIPlus_RegionCreateFromPath($hPath2)
                _GDIPlus_RegionCombineRegion($hRegion1, $hRegion2, 1) ;combine lighter circle with darker circle

                _GDIPlus_BrushSetSolidColor($hBrush, $aColors[$i][1]) ;lighter ball color
                _GDIPlus_GraphicsFillPath($hGfx, $hPath1, $hBrush)

                _GDIPlus_BrushSetSolidColor($hBrush, $aColors[$i][0]) ;darker ball color
                _GDIPlus_GraphicsFillRegion($hGfx, $hRegion1, $hBrush)

                _GDIPlus_GraphicsDrawPath($hGfx, $hPath1, $hPen) ;draw circle frame

                _GDIPlus_RegionDispose($hRegion1)
                _GDIPlus_RegionDispose($hRegion2)
                _GDIPlus_PathReset($hPath1)
                _GDIPlus_PathReset($hPath2)
        Next
        $fSpeed += 0.0261799

        Local $iW_Progressbar = $iW / 2 + 4
        _GDIPlus_PenSetColor($hPen, 0xD048D1CC)
        _GDIPlus_GraphicsDrawRect($hGfx, ($iW - $iW_Progressbar) / 2, $iH - 50, $iW_Progressbar, 14, $hPen)
        _GDIPlus_BrushSetSolidColor($hBrush, 0xFFAFEEEE)
        _GDIPlus_GraphicsFillRect($hGfx, ($iW - $iW_Progressbar) / 2 + 2, $iH - 48, $fPerc * ($iW_Progressbar - 4) / 100, 10, $hBrush)

        _GDIPlus_PenSetColor($hPen, 0x20000000)
        _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iW, $iH, $hPen) ;draw window frame

        _GDIPlus_PathDispose($hPath1)
        _GDIPlus_PathDispose($hPath2)
        _GDIPlus_PenDispose($hPen)
        _GDIPlus_BrushDispose($hBrush)

        _GDIPlus_GraphicsDispose($hGfx)

        If $bHBitmap Then
                Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
                _GDIPlus_BitmapDispose($hBitmap)
                Return $hHBITMAP
        EndIf
        Return $hBitmap
EndFunc
 楼主| 发表于 2017-6-29 17:58:01 | 显示全部楼层
余辉效果
;by Eukalyptus
;AutoIt v3.3.9.21 or higher needed!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172
Global $iW = 380, $iH = 260
Global $hGui = GUICreate("Loading", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global $cPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()

Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 20, $fPower = 4

GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGui, "int", 0, "int", $iSleep, "int", 0)

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIRegisterMsg($WM_TIMER, "")
            _WinAPI_DeleteObject($hHBmp_BG)
            _GDIPlus_Shutdown()
            GUIDelete()
            Exit
    EndSwitch
Until False

Func PlayAnim()
    $hHBmp_BG = _GDIPlus_SpinningAndGlowing($iPerc, $iW, $iH)
    $hB = GUICtrlSendMsg($cPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    $iPerc += $fPower
EndFunc   ;==>PlayAnim


Func _GDIPlus_SpinningAndGlowing($fProgress, $iW, $iH, $iColor = 0xFF6644FF, $fSize = 80, $iCnt = 24, $fDM = 24, $fScale = 3, $iGlowCnt = 6)
    Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx, 2)
    _GDIPlus_GraphicsClear($hGfx, 0xFF141414)

    Local $iOff = $iCnt * Mod($fProgress, 100) / 100
    Local $fCX = $iW * 0.5
    Local $fCY = $iH * 0.5

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, -$fDM * 0.5, -$fDM * 0.5, $fDM, $fDM)
    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, $iColor)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aBlend[5][2] = [[4]]
    $aBlend[1][0] = 0
    $aBlend[1][1] = 0
    $aBlend[2][0] = BitOR(BitAND($iColor, 0x00FFFFFF), 0x1A000000)
    $aBlend[2][1] = 0.78
    $aBlend[3][0] = BitOR(BitAND($iColor, 0x00FFFFFF), 0xFF000000)
    $aBlend[3][1] = 0.88
    $aBlend[4][0] = 0xFFFFFFFF
    $aBlend[4][1] = 1
    _GDIPlus_PathBrushSetPresetBlend($hBrush, $aBlend)

    Local $fS
    Local Const $cPI = ATan(1) * 4
    For $i = 0 To $iCnt - 1
        $fS = Sin($cPI * Log(1.4 + Mod($iOff + $i, $iCnt) / $iGlowCnt) / Log(4))
        If $fS < 0 Then $fS = 0
        $fS = 1 + $fScale * $fS

        _GDIPlus_GraphicsResetTransform($hGfx)
        _GDIPlus_GraphicsScaleTransform($hGfx, $fS, $fS, True)
        _GDIPlus_GraphicsTranslateTransform($hGfx, -$fSize, 0, True)
        _GDIPlus_GraphicsScaleTransform($hGfx, 1.2, 1, False)
        _GDIPlus_GraphicsRotateTransform($hGfx, -360 / $iCnt * $i, True)
        _GDIPlus_GraphicsTranslateTransform($hGfx, $fCX, $fCY, True)

        _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush)
    Next

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)


    Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_BitmapDispose($hBmp)
    Return $hHBITMAP
EndFunc   ;==>_GDIPlus_SpinningAndGlowing
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-21 20:35 , Processed in 0.090021 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表