找回密码
 加入
搜索
查看: 3690|回复: 9

[系统综合] 如何实现鼠标在屏幕上两点移动时的抛物线轨迹

  [复制链接]
发表于 2014-9-4 00:49:49 | 显示全部楼层 |阅读模式
请教如何实现鼠标在屏幕上的两点(x0,y0)到(x1,y1)之间移动时的抛物线轨迹,其中暂以(x0,y0)为抛物线的顶点,抛物线的开口向左、右、上、下均可,当然若 x0=x1 或 y0=y1 则做水平或垂直方向上的直线移动(轨迹)
 楼主| 发表于 2014-9-4 10:38:41 | 显示全部楼层
烦请autoit高手帮忙想想辙
发表于 2014-9-4 11:04:07 | 显示全部楼层
2点能形成抛物线? 2点永远是一线吧. (y1-y0)/(x1-x0)是斜率. 可能没懂你的意思.你先用2点画个抛物线给大家看看.也许知道你说的是什么
发表于 2014-9-6 07:56:01 | 显示全部楼层
函数图象吗好办的很
发表于 2014-9-8 20:04:13 | 显示全部楼层
我也想知道!
发表于 2014-9-8 21:47:49 | 显示全部楼层
mousemov有速度控制啊 只要不是0  就有轨迹啊
发表于 2014-9-10 23:39:12 | 显示全部楼层
貌似不是很难吧
发表于 2014-9-27 19:52:01 | 显示全部楼层
[au3]#include <Math.au3>
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
        Local $hGUI, $hWnd, $hGraphic, $hBrush, $hAsymPen, $hFormat, $hFamily, $hFont, $tLayout, $hPen
        Local $aPoint[10000][3], $aPoint2[10000][3], $j = 1

        ; 创建界面
        $hGUI = GUICreate("Parabola", 400, 300)
        $hWnd = WinGetHandle("Parabola")
        GUISetState()

        _GDIPlus_Startup()
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
        $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
        $hFormat = _GDIPlus_StringFormatCreate()
        $hFamily = _GDIPlus_FontFamilyCreate("Arial")
        $hFont = _GDIPlus_FontCreate($hFamily, 8, 2)
        $tLayout = _GDIPlus_RectFCreate(200, 150, 50, 20)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, 'O(0,0)', $hFont, $tLayout, $hFormat, $hBrush)
        $tLayout = _GDIPlus_RectFCreate(20, 20, 200, 20)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, '', $hFont, $tLayout, $hFormat, $hBrush)
        $tLayout = _GDIPlus_RectFCreate(100, 150, 50, 20)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, '-1', $hFont, $tLayout, $hFormat, $hBrush)
        $tLayout = _GDIPlus_RectFCreate(300, 150, 50, 20)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, '1', $hFont, $tLayout, $hFormat, $hBrush)
        $hPen = _GDIPlus_PenCreate()
        _GDIPlus_GraphicsDrawLine($hGraphic, 0, 150, 400, 150, $hPen)
        _GDIPlus_GraphicsDrawLine($hGraphic, 200, 0, 200, 300, $hPen)
        $hAsymPen = _GDIPlus_PenCreate()
        _GDIPlus_PenSetDashStyle($hAsymPen, $GDIP_DASHSTYLEDASH)
        _GDIPlus_GraphicsDrawLine($hGraphic, 100, 0, 100, 300, $hAsymPen)
        _GDIPlus_GraphicsDrawLine($hGraphic, 300, 0, 300, 300, $hAsymPen)

        $aPoint[0][0] = 200
        $aPoint2[0][0] = 200
        For $i = 0 To 200 Step 1
                $aPoint[$j][0] = $i * 2 + 200
                $aPoint[$j][1] = 150 - Sqrt($i * 2)
                $aPoint2[$j][0] = $i * 2 + 200
                $aPoint2[$j][1] = 150 + Sqrt($i * 2)
                $j += 1
        Next
        _GDIPlus_GraphicsDrawCurve($hGraphic, $aPoint)
        _GDIPlus_GraphicsDrawCurve($hGraphic, $aPoint2)
       
        ; 循环至用户退出
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        ; 清除资源
        _GDIPlus_PenDispose($hPen)
        _GDIPlus_PenDispose($hAsymPen)
        _GDIPlus_FontDispose($hFont)
        _GDIPlus_FontFamilyDispose($hFamily)
        _GDIPlus_StringFormatDispose($hFormat)
        _GDIPlus_BrushDispose($hBrush)
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_Shutdown()

EndFunc   ;==>_Main
[/au3]
发表于 2014-9-27 19:57:26 | 显示全部楼层
[au3]
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
        Local $hGUI, $hWnd, $hGraphic, $hBrush, $hAsymPen, $hFormat, $hFamily, $hFont, $tLayout, $hPen
        Local $aPoint[10000][3], $aPoint2[10000][3], $j = 1

        ; 创建界面
        $hGUI = GUICreate("Parabola", 400, 300)
        $hWnd = WinGetHandle("Parabola")
        GUISetState()

        _GDIPlus_Startup()
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
        $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
        $hFormat = _GDIPlus_StringFormatCreate()
        $hFamily = _GDIPlus_FontFamilyCreate("Arial")
        $hFont = _GDIPlus_FontCreate($hFamily, 8, 2)
        $tLayout = _GDIPlus_RectFCreate(200, 150, 50, 20)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, 'O(0,0)', $hFont, $tLayout, $hFormat, $hBrush)
        $tLayout = _GDIPlus_RectFCreate(20, 20, 200, 20)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, '', $hFont, $tLayout, $hFormat, $hBrush)
        $tLayout = _GDIPlus_RectFCreate(100, 150, 50, 20)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, '-1', $hFont, $tLayout, $hFormat, $hBrush)
        $tLayout = _GDIPlus_RectFCreate(300, 150, 50, 20)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, '1', $hFont, $tLayout, $hFormat, $hBrush)
        $hPen = _GDIPlus_PenCreate()
        _GDIPlus_GraphicsDrawLine($hGraphic, 0, 150, 400, 150, $hPen)
        _GDIPlus_GraphicsDrawLine($hGraphic, 200, 0, 200, 300, $hPen)
        $hAsymPen = _GDIPlus_PenCreate()
        _GDIPlus_PenSetDashStyle($hAsymPen, $GDIP_DASHSTYLEDASH)
        _GDIPlus_GraphicsDrawLine($hGraphic, 100, 0, 100, 300, $hAsymPen)
        _GDIPlus_GraphicsDrawLine($hGraphic, 300, 0, 300, 300, $hAsymPen)

        $aPoint[0][0] = 200
        $aPoint2[0][0] = 200
        For $i = 0 To 200 Step 1
                $aPoint[$j][0] = $i * 2 + 200
                $aPoint[$j][1] = 150 - Sqrt($i * 2)
                $aPoint2[$j][0] = $i * 2 + 200
                $aPoint2[$j][1] = 150 + Sqrt($i * 2)
                $j += 1
        Next
        _GDIPlus_GraphicsDrawCurve($hGraphic, $aPoint)
        _GDIPlus_GraphicsDrawCurve($hGraphic, $aPoint2)
       
        ; 循环至用户退出
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        ; 清除资源
        _GDIPlus_PenDispose($hPen)
        _GDIPlus_PenDispose($hAsymPen)
        _GDIPlus_FontDispose($hFont)
        _GDIPlus_FontFamilyDispose($hFamily)
        _GDIPlus_StringFormatDispose($hFormat)
        _GDIPlus_BrushDispose($hBrush)
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_Shutdown()

EndFunc   ;==>_Main
[/au3]
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-23 15:32 , Processed in 0.083486 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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