几种线性递增的方法

找到几种线性递增找怪的方法,不过效率特低,没有选用。不过感觉挺好玩的。

脚本

//从附件释放大漠插件并注册
//PutAttachment "c:\test_game","*.*"
//PutAttachment ".\Plugin", "RegDll.dll"
//call Plugin.Regdll.reg("c:\test_game\dm.dll")

//设置大漠路径以及字库名
Set dm = createobject("dm.dmsoft")
dm.SetPath ("d:")
//dm_ret = dm.SetDict(0,"lanhuo.txt")
//字库

//绑定当前鼠标位置程序为前台操作模式
hwnd = dm.GetMousePointWindow()
dm_ret = dm.BindWindow(hwnd,"normal","normal","normal",0)

call 椭圆()
call 圆形()
call 方形()

Sub 椭圆()
    Dim x0, n, y0, x, color0, color1
    x0 = 800 : n = 1 : y0 = 600 : x = 800
    //变量初始化
    l = 10
    //设置2点间距离
    While x < 1024
        //限定横坐标范围不超过1024
        x = x0 + 4 * (cos(n) + n * sin(n))
        y = y0 + 3 * (sin(n) - n * cos(n))
        color0 = GetPixelColor(x, y)
        dm.moveTo x, y
        dm.leftclick
        color1 = GetPixelColor(x, y)
        If color1 <> color0 Then 
            dm.LeftClick
            Delay 1000
        End If
        Delay 10
        n = n + 0.2
        //渐开线参数增量,其中0.2代表点间距,数值越小,渐开线散开点间距越小
        r = Sqr((x - x0) ^ 2 + (y - y0) ^ 2)
        //计算当前点(x,y)到原点(x0,y0)的距离
        n = n + l / r
        //渐开线参数增量,其中l/r:点距除以半径,取得2点间相对圆心的角度
        //能有效控制扫描点的密度,2点间的距离就比较平均
    Wend
End Sub

Sub 圆形()
    //设置圆心坐标
    x0=800:y0=600
    //设置递增半径
    rr=20
    //设置点间距
    l=20
    //初始化角度
    n=0
    //设置第一圈半径
    r=30
    //画圆圈数
    For 10
        While n<3.1415926*2
            //画圆公式
            x=x0+r*cos(n)
            y=y0-r*sin(n)
            dm.MoveTo x,y
            dm.LeftClick
            Delay 10
            //l/r:点距除以半径,取得2点间相对圆心的角度
            //能有效控制扫描点的密度,2点间的距离就比较平均
            n=n+l/r
        Wend
        //画完一圈后重置角度
        n=0
        //画完一圈后半径递增rr
        r=r+rr
    Next
End Sub

Sub 方形()
    //设置中心点
    x=400:y=300
    //设置2点间距离
    v=10
    i=1
    //循环20次,即画20圈
    For 20
        j=0:k=v
        For 2
            For i
                x=x+j:y=y+k
                dm.MoveTo x,y
                dm.LeftClick
                Delay 10
            Next
            j=v:k=0
        Next
        i=i+1:v=v*(-1)
    Next
End Sub

你可能感兴趣的:(几种线性递增的方法)