a11s.Net

年纪大了,脑子不好用了,需要记录写东西了

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

转载请注明来自 http://a11s.cnblogs.com  作者:董含君

计划是做魔法阵生成器的,后来仔细研究,需要大量的解析几何 数据结构 拼凑算法 随机算法 等等相关内容,所以不可能一次性解决问题了.所以发来当前进度描述一下过程以及想法.不一定能坚持写下去,到了后面的规则制定我头都大了.

--------------------------------------------------------------------------
用途:计算2D飞行游戏弹道,比如彩京那样的,放置游戏人物,屏幕保护,媒体播放器的视觉效果.

一个6边形,根据r扩散.取r两次.则有两个顶点列表.根据这两个停电列表可以表示弹道轨迹.然后旋转魔法阵,得到新的顶点列表,重复上述操作,可以得到任意发散的子弹图形
如果对两个子弹的弹道加上初始速度以及加速度,则可以表示变速直线运动,创造更华丽的子弹组合效果.
如果有了随机生成魔法阵算法,理论上游戏人物的初始位置排列都可以生成
虽然可以随机出现,但是如果用魔法阵顶点来做,会更有规律,生成的敌人组合排列更强,更加合理.因为魔法阵的生成都是有规律的,攻击型的图形表示可以放攻击型人物等等
因为牵扯随机算法,就是给出要求("比如咒语"),然后根据条件生成魔法阵的过程,就是要求根据"指定规则"后的映射
比如你给出一系列条件:攻击型5个,防御性一个,防御为主,同时复杂程度不超过N(魔法阵外层常量)....其他条件等等.然后根据算法,提取出数字,用作权值.生成魔法阵
N的取得是根据权值而定,就是N越大,魔法阵面积越大,外围图形越多(有隐形的辅助线) 而且如果敌人有人死亡,比如攻击的减少了一个,而且还是防御为主..那么再次带入还能生成新的魔法阵 重新排列防守阵型

强烈怀疑,一开始提出魔法阵的人,绝对不是因为好看!!只不过没有人认真研究罢了.这个很像八卦阵的,全都是数学以及数据关系
---------------------------------------------------------------------------

不废话了...

魔法阵生成系统的第一步 画一个正N角星

这个是基础的基础,正N角星包含正N边形,当N大于一定程度的时候可以近似表示圆,我们需要的顶点列表都可以被线性表描述出来,从而根据下标筛选所需的点.

对于正N角星,基础就是所在外接圆,然后通过极坐标->平面坐标转化求出顶点

这个就很简单了,高中内容

-------------------极坐标 到 平面坐标的转化--------------
 Function Trans(ByVal jizuobiao As CAPI, Optional ByVal StartX As Integer = CStartX, Optional ByVal StartY As Integer = CStartY) As System.Drawing.Point
        Dim P As System.Drawing.Point
        'P(x,y)就是极坐标的 (Sin a)x 半径r 以及cos a x半径r
        P.X = StartX + CLng(Math.Sin(jizuobiao.a) * jizuobiao.r)
        P.Y = StartY + CLng(Math.Cos(jizuobiao.a) * jizuobiao.r)
        Trans = P
    End Function
----------------------------------------------------------------------

另外微软提供的arraylist似乎没有环形链表,尝试用他的queuq的时候,也不好改动,于是我索性干脆自己写了一个.其中包含以下要素:
-------------------------------
Public Class Node
    '下一个节点
    Public NextNode As Node
    Public Container As RoundQueue
    '上一个节点
    Public PrevNode As Node
    '元素信息,用Object表示
    Public objData As Object
    Public visitFlas As Integer
 '插入节点
    Public Function InsertNextByData(ByRef d As Object) As Node
Public Sub deleteNode()
Protected Overrides Sub Finalize()
End Class
Public Class RoundQueue

    'Public EnableBack As Boolean
    '虚拟的头节点
    Public Root As Node
    Public TotalNodes As Long       '总数
    Public CurrentNode As Node      '当前指针
    Public Sub New()
    Public Sub New(ByRef L As ArrayList)
    Public Function InsertNode(ByRef tarNode As Node, ByRef newNode As Node) As Node
    Public Function InsertNode(ByRef tarNode As Node, ByRef newNode As Node, ByRef DataOfNewNode As Object)
    Public Function MovePrev() As Node
    Public Property GetData() As Object
    Protected Overrides Sub Finalize()
    Public Sub Dispose()
End Class
--------------------------------------------------


有了以上材料作为基础,开始研究算法.
网上找到的大部分都是LOGO语言的,没办法,人家天生适合画这个.
给出函数 
DrawAngle(ByVal Num As Long, ByVal Steps As Long, ByRef map As Bitmap, ByVal x As Long, ByVal y As Long, ByVal r As Long, ByVal basea As Single, ByVal penA As Drawing.Pen)
提供角的数量,跨越点数,目标图像,圆心半径起始角度(用于旋转),以及画笔(颜色,粗细)绘制图形

1 所有的大于2的奇数的正N角星都能一笔画出
(也就是我们可以一直用.nextnode来画)
2 除了六角星以外 所有大于3的正N角星都能一笔画出
(一笔画出就是没有跳跃间断点)
3 大于5的正N角星,会有 ((边数-1)/2)上取整种有效画法
不仅仅是一种画法,当边数等于0或者自身的时候无意义,重复的图形无意义
4 间断点位置,(当角的数量/间隔点差(包含自身))=K的余数为0的点就是断点.
5 当断点出现的时候,当前图形就是基本图形,整个图形在此基础上错位 K次就是整个图形
6 基本图形错位K次的结果不会有任何重复线段以及顶点,而且可以遍历整个节点

以下以正8角星为例(3,4,5,6都有特例,所以不好办) 如图


------------------------------------

算法:
1 创建m的元素的数组
2 根据m的个数,取得间隔的角度a
3 根据极坐标转化,得到第一个顶点的位置
4 依次类推取得全部顶点

5 将顶点加入环形链表(严格的说,不算队列)
6 绘制,检测错位
--------------
  For i = 1 To RQ.TotalNodes
            If RQ.CurrentNode.visitFlas = 1 And GetNextNNode(RQ.CurrentNode, Steps).visitFlas = 1 Then
                '如果下一个节点的下一个节点已经访问那么
                RQ.MoveNext()
                If i < RQ.TotalNodes - 1 Then i = i - 1
            Else
                g.DrawLine(penA, RQ.CurrentNode.objData, MoveNextNNode(RQ.CurrentNode, Steps).objData)
                RQ.CurrentNode.visitFlas = 1
            End If
        Next
-------------
最终效果:




源代码:



Module Module1

 

 

 

    Function DrawAngle(ByVal Num As Long, ByVal Steps As Long, ByRef map As Bitmap, ByVal x As Long, ByVal y As Long, ByVal r As Long, ByVal basea As Single, ByVal penA As Drawing.Pen)

 

 

 

        If map Is Nothing Then

            Exit Function

        End If

        Dim g As System.Drawing.Graphics

        g = g.FromImage(map)

        Dim RQ As RoundQueue = CreatePointQueueA(x, y, r, Num, basea)

        Dim i As Long

 

 

 

        ''''''''' Draw

        For i = 1 To RQ.TotalNodes

            If RQ.CurrentNode.visitFlas = 1 And GetNextNNode(RQ.CurrentNode, Steps).visitFlas = 1 Then

                '如果下一个节点的下一个节点已经访问那么

                RQ.MoveNext()

                If i < RQ.TotalNodes - 1 Then i = i - 1

            Else

                g.DrawLine(penA, RQ.CurrentNode.objData, MoveNextNNode(RQ.CurrentNode, Steps).objData)

                RQ.CurrentNode.visitFlas = 1

            End If

        Next

 

 

 

    End Function

    Sub DrawLine(ByVal fromPoint As Drawing.Point, ByVal toPoint As Drawing.Point)

 

 

 

    End Sub

    Function GetNextNNode(ByVal tarnode As Node, ByVal n As Long) As Node

        Dim i

        For i = 1 To n

            tarnode = tarnode.NextNode

        Next

        Return tarnode

    End Function

    Function MoveNextNNode(ByRef tarnode As Node, ByVal n As Long) As Node

        Dim i

        For i = 1 To n

            tarnode = tarnode.NextNode

        Next

        Return tarnode

    End Function

 

 

 

End Module

 

 

 

Public Class RoundQueue

 

 

 

    'Public EnableBack As Boolean

    '虚拟的头节点

    Public Root As Node

    Public TotalNodes As Long       '总数

    Public CurrentNode As Node      '当前指针

 

 

 

    ''''''''

    Public Sub New()

        '新的根节点

        Root = New Node

        '全部指向自己

        Root.PrevNode = Root

        Root.NextNode = Root

 

 

 

        '当前节点指向跟节点

        CurrentNode = Root

        Root.Container = Me

 

 

 

        TotalNodes = 1

    End Sub

    Public Sub New(ByRef L As ArrayList)

 

 

 

        Me.New()

        If L.Count < 0 Then Exit Sub

        Root.objData = L.Item(0)

        Dim i As Long

        For i = 1 To L.Count - 1

            Dim cn As Node

            If i = 1 Then

                cn = InsertNode(Root, New Node, L.Item(i))

 

 

 

            Else

                cn = InsertNode(CurrentNode, New Node, L.Item(i))

 

 

 

            End If

            cn.objData = cn.objData

            CurrentNode.NextNode = cn

        Next

        Root = CurrentNode

        Root = Root.NextNode

 

 

 

        '最后一个节点指向头节点

        'CurrentNode.PrevNode = Root

        '头节点的上一个节点指向最后一个

        'Root.PrevNode = CurrentNode

        '指针移动到开始

        'CurrentNode = Root

 

 

 

 

 

 

 

 

 

    End Sub

    Public Function InsertNode(ByRef tarNode As Node, ByRef newNode As Node) As Node

        '保存旧的数据

        Dim oldnode As Node

        oldnode = tarNode.NextNode

        '连接新的数据

        tarNode.NextNode = newNode

        newNode.PrevNode = tarNode

        newNode.NextNode = oldnode

        '连接旧的数据

        oldnode.PrevNode = newNode

        '返回刚刚插入的Node

        TotalNodes += 1

        newNode.Container = Me

 

 

 

        Return newNode

 

 

 

    End Function

    Public Function InsertNode(ByRef tarNode As Node, ByRef newNode As Node, ByRef DataOfNewNode As Object)

        '保存旧的数据

        Dim oldnode As Node

        oldnode = tarNode.NextNode

        '连接新的数据

        tarNode.NextNode = newNode

        newNode.PrevNode = tarNode

        newNode.NextNode = oldnode

        '连接旧的数据

        oldnode.PrevNode = newNode

 

 

 

        newNode.objData = DataOfNewNode

        newNode.Container = Me

        TotalNodes += 1

        Return newNode

    End Function

    Public Function MoveNext() As Node

        CurrentNode = CurrentNode.NextNode

    End Function

    Public Function MovePrev() As Node

        CurrentNode = CurrentNode.PrevNode

    End Function

    Public Property GetData() As Object

        Get

            Return CurrentNode.objData

        End Get

        Set(ByVal Value As Object)

            CurrentNode.objData = Value

        End Set

    End Property

 

 

 

    Protected Overrides Sub Finalize()

        MyBase.Finalize()

    End Sub

    Public Sub Dispose()

        Finalize()

    End Sub

End Class

Public Class Node

    '下一个节点

    Public NextNode As Node

    Public Container As RoundQueue

    '上一个节点

    Public PrevNode As Node

    '元素信息,Object表示

    Public objData As Object

    Public visitFlas As Integer

 

 

 

    '插入节点

    Public Function InsertNextByData(ByRef d As Object) As Node

        Dim n As New Node       'new

        n.objData = d           'add data

        n.PrevNode = Me         '确定前驱

        Me.NextNode = n         '自己确定后继

        Container.TotalNodes += 1

        Return n                '返回

 

 

 

 

 

 

    End Function

    Public Sub deleteNode()

        'Dim t As Node

        't = Me.NextNode

        If Container.TotalNodes <= 1 Then

            Me.Finalize()

            Container.Dispose()

        End If

        Me.PrevNode.NextNode = Me.NextNode

        Me.NextNode.PrevNode = Me.PrevNode

        Me.Finalize()

 

 

 

 

 

 

    End Sub

 

 

 

    Protected Overrides Sub Finalize()

        MyBase.Finalize()

    End Sub

End Class

 

 

 

 

 

 

Public Class Form1

    Inherits System.Windows.Forms.Form

 

 

 

#Region " Windows 窗体设计器生成的代码 "

 

 

 

    Public Sub New()

        MyBase.New()

 

 

 

        '该调用是 Windows 窗体设计器所必需的。

        InitializeComponent()

 

 

 

        ' InitializeComponent() 调用之后添加任何初始化

 

 

 

    End Sub

 

 

 

    '窗体重写 dispose 以清理组件列表。

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing Then

            If Not (components Is Nothing) Then

                components.Dispose()

            End If

        End If

        MyBase.Dispose(disposing)

    End Sub

 

 

 

    'Windows 窗体设计器所必需的

    Private components As System.ComponentModel.IContainer

 

 

 

    '注意: 以下过程是 Windows 窗体设计器所必需的

    '可以使用 Windows 窗体设计器修改此过程。

    '不要使用代码编辑器修改它。

    Friend WithEvents Button1 As System.Windows.Forms.Button

    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox

    Friend WithEvents Button2 As System.Windows.Forms.Button

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        Me.Button1 = New System.Windows.Forms.Button

        Me.ListBox1 = New System.Windows.Forms.ListBox

        Me.Button2 = New System.Windows.Forms.Button

        Me.SuspendLayout()

        '

        'Button1

        '

        Me.Button1.Location = New System.Drawing.Point(360, 96)

        Me.Button1.Name = "Button1"

        Me.Button1.Size = New System.Drawing.Size(120, 48)

        Me.Button1.TabIndex = 0

        Me.Button1.Text = "next"

        '

        'ListBox1

        '

        Me.ListBox1.ItemHeight = 12

        Me.ListBox1.Location = New System.Drawing.Point(16, 8)

        Me.ListBox1.Name = "ListBox1"

        Me.ListBox1.Size = New System.Drawing.Size(200, 316)

        Me.ListBox1.TabIndex = 1

        '

        'Button2

        '

        Me.Button2.Location = New System.Drawing.Point(360, 168)

        Me.Button2.Name = "Button2"

        Me.Button2.Size = New System.Drawing.Size(120, 48)

        Me.Button2.TabIndex = 2

        Me.Button2.Text = "prve"

        '

        'Form1

        '

        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)

        Me.ClientSize = New System.Drawing.Size(496, 373)

        Me.Controls.Add(Me.Button2)

        Me.Controls.Add(Me.ListBox1)

        Me.Controls.Add(Me.Button1)

        Me.Name = "Form1"

        Me.Text = "Form1"

        Me.ResumeLayout(False)

 

 

 

    End Sub

 

 

 

#End Region

    Dim lianbiao As RoundQueue

    Dim arr As New ArrayList

    Dim i As Long

 

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

 

 

        ListBox1.Items.Clear()

        For i = 1 To 30

            ListBox1.Items.Add(lianbiao.CurrentNode.objData)

            lianbiao.CurrentNode = lianbiao.CurrentNode.NextNode

        Next

    End Sub

 

 

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        For i = 1 To 7

            arr.Add("" + i.ToString + "")

        Next

        lianbiao = New RoundQueue(arr)

        lianbiao.CurrentNode = lianbiao.Root

 

 

 

    End Sub

 

 

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        ListBox1.Items.Clear()

        For i = 1 To 30

            ListBox1.Items.Add(lianbiao.CurrentNode.objData)

            lianbiao.CurrentNode = lianbiao.CurrentNode.PrevNode

        Next

    End Sub

End Class

 

 

 

 

 

 

Module Module2

    Public Const PI = 3.141592654

    Public Const CStartX = 200

    Public Const CStartY = 200

 

 

 

    Public Structure CAPI

        Public a As Single

        Public r As Single

    End Structure

 

 

 

    Function Trans(ByVal jizuobiao As CAPI, Optional ByVal StartX As Integer = CStartX, Optional ByVal StartY As Integer = CStartY) As System.Drawing.Point

        Dim P As System.Drawing.Point

        P.X = StartX + CLng(Math.Sin(jizuobiao.a) * jizuobiao.r)

        P.Y = StartY + CLng(Math.Cos(jizuobiao.a) * jizuobiao.r)

        Trans = P

 

 

 

 

 

 

    End Function

    Public Function CreatePointQueueA(ByVal x As Long, ByVal y As Long, ByVal r As Long, ByVal itemscount As Long, Optional ByVal Basea As Single = 0) As RoundQueue

        Dim q As New RoundQueue

        Dim a As Single

        Dim j As CAPI

 

 

 

        a = 2 * Math.PI / itemscount

        Dim PointList(itemscount - 1) As Drawing.Point

        '''Now Create list

        Dim i As Long

        For i = 0 To itemscount - 1

            j.a = Basea + a * (i + 1)

            j.r = r

            PointList(i) = Trans(j, x, y)

        Next

        '''enqueue

        Dim RQ As New RoundQueue(New ArrayList(PointList))

        Return RQ

 

 

 

    End Function

 

 

 

End Module

 

 

 

 

 

 

Public Class Form2

    Inherits System.Windows.Forms.Form

    Dim penA As Pen

#Region " Windows 窗体设计器生成的代码 "

 

 

 

    Public Sub New()

        MyBase.New()

 

 

 

        '该调用是 Windows 窗体设计器所必需的。

        InitializeComponent()

 

 

 

        ' InitializeComponent() 调用之后添加任何初始化

 

 

 

    End Sub

 

 

 

    '窗体重写 dispose 以清理组件列表。

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing Then

            If Not (components Is Nothing) Then

                components.Dispose()

            End If

        End If

        MyBase.Dispose(disposing)

    End Sub

 

 

 

    'Windows 窗体设计器所必需的

    Private components As System.ComponentModel.IContainer

 

 

 

    '注意: 以下过程是 Windows 窗体设计器所必需的

    '可以使用 Windows 窗体设计器修改此过程。

    '不要使用代码编辑器修改它。

    Friend WithEvents Button1 As System.Windows.Forms.Button

    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

    Friend WithEvents Label1 As System.Windows.Forms.Label

    Friend WithEvents Label2 As System.Windows.Forms.Label

    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox

    Friend WithEvents Label3 As System.Windows.Forms.Label

    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox

    Friend WithEvents Label4 As System.Windows.Forms.Label

    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox

    Friend WithEvents Label5 As System.Windows.Forms.Label

    Friend WithEvents TextBox5 As System.Windows.Forms.TextBox

    Friend WithEvents Label6 As System.Windows.Forms.Label

    Friend WithEvents VScrollBar1 As System.Windows.Forms.VScrollBar

    Friend WithEvents Label7 As System.Windows.Forms.Label

    Friend WithEvents Label8 As System.Windows.Forms.Label

    Friend WithEvents TextBox7 As System.Windows.Forms.TextBox

    Friend WithEvents Button2 As System.Windows.Forms.Button

    Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        Me.Button1 = New System.Windows.Forms.Button

        Me.PictureBox1 = New System.Windows.Forms.PictureBox

        Me.TextBox1 = New System.Windows.Forms.TextBox

        Me.Label1 = New System.Windows.Forms.Label

        Me.Label2 = New System.Windows.Forms.Label

        Me.TextBox2 = New System.Windows.Forms.TextBox

        Me.Label3 = New System.Windows.Forms.Label

        Me.TextBox3 = New System.Windows.Forms.TextBox

        Me.Label4 = New System.Windows.Forms.Label

        Me.TextBox4 = New System.Windows.Forms.TextBox

        Me.Label5 = New System.Windows.Forms.Label

        Me.TextBox5 = New System.Windows.Forms.TextBox

        Me.Label6 = New System.Windows.Forms.Label

        Me.VScrollBar1 = New System.Windows.Forms.VScrollBar

        Me.Label7 = New System.Windows.Forms.Label

        Me.Label8 = New System.Windows.Forms.Label

        Me.TextBox7 = New System.Windows.Forms.TextBox

        Me.Button2 = New System.Windows.Forms.Button

        Me.ColorDialog1 = New System.Windows.Forms.ColorDialog

        Me.SuspendLayout()

        '

        'Button1

        '

        Me.Button1.Location = New System.Drawing.Point(424, 8)

        Me.Button1.Name = "Button1"

        Me.Button1.Size = New System.Drawing.Size(104, 32)

        Me.Button1.TabIndex = 0

        Me.Button1.Text = "Draw It!!"

        '

        'PictureBox1

        '

        Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

        Me.PictureBox1.Location = New System.Drawing.Point(8, 64)

        Me.PictureBox1.Name = "PictureBox1"

        Me.PictureBox1.Size = New System.Drawing.Size(440, 328)

        Me.PictureBox1.TabIndex = 1

        Me.PictureBox1.TabStop = False

        '

        'TextBox1

        '

        Me.TextBox1.Location = New System.Drawing.Point(72, 8)

        Me.TextBox1.Name = "TextBox1"

        Me.TextBox1.Size = New System.Drawing.Size(40, 21)

        Me.TextBox1.TabIndex = 2

        Me.TextBox1.Text = "7"

        '

        'Label1

        '

        Me.Label1.Location = New System.Drawing.Point(16, 16)

        Me.Label1.Name = "Label1"

        Me.Label1.Size = New System.Drawing.Size(56, 16)

        Me.Label1.TabIndex = 3

        Me.Label1.Text = "角的数量"

        '

        'Label2

        '

        Me.Label2.Location = New System.Drawing.Point(120, 16)

        Me.Label2.Name = "Label2"

        Me.Label2.Size = New System.Drawing.Size(32, 16)

        Me.Label2.TabIndex = 4

        Me.Label2.Text = "间隔"

        '

        'TextBox2

        '

        Me.TextBox2.Location = New System.Drawing.Point(152, 8)

        Me.TextBox2.Name = "TextBox2"

        Me.TextBox2.Size = New System.Drawing.Size(40, 21)

        Me.TextBox2.TabIndex = 5

        Me.TextBox2.Text = "1"

        '

        'Label3

        '

        Me.Label3.Location = New System.Drawing.Point(200, 16)

        Me.Label3.Name = "Label3"

        Me.Label3.Size = New System.Drawing.Size(32, 16)

        Me.Label3.TabIndex = 6

        Me.Label3.Text = "半径"

        '

        'TextBox3

        '

        Me.TextBox3.Location = New System.Drawing.Point(232, 8)

        Me.TextBox3.Name = "TextBox3"

        Me.TextBox3.Size = New System.Drawing.Size(40, 21)

        Me.TextBox3.TabIndex = 30

        Me.TextBox3.Text = "50"

        '

        'Label4

        '

        Me.Label4.Location = New System.Drawing.Point(280, 16)

        Me.Label4.Name = "Label4"

        Me.Label4.Size = New System.Drawing.Size(8, 16)

        Me.Label4.TabIndex = 31

        Me.Label4.Text = "X"

        '

        'TextBox4

        '

        Me.TextBox4.Location = New System.Drawing.Point(296, 8)

        Me.TextBox4.Name = "TextBox4"

        Me.TextBox4.Size = New System.Drawing.Size(40, 21)

        Me.TextBox4.TabIndex = 32

        Me.TextBox4.Text = "200"

        '

        'Label5

        '

        Me.Label5.Location = New System.Drawing.Point(336, 16)

        Me.Label5.Name = "Label5"

        Me.Label5.Size = New System.Drawing.Size(8, 16)

        Me.Label5.TabIndex = 33

        Me.Label5.Text = "Y"

        '

        'TextBox5

        '

        Me.TextBox5.Location = New System.Drawing.Point(352, 8)

        Me.TextBox5.Name = "TextBox5"

        Me.TextBox5.Size = New System.Drawing.Size(40, 21)

        Me.TextBox5.TabIndex = 34

        Me.TextBox5.Text = "150"

        '

        'Label6

        '

        Me.Label6.Location = New System.Drawing.Point(480, 64)

        Me.Label6.Name = "Label6"

        Me.Label6.Size = New System.Drawing.Size(32, 16)

        Me.Label6.TabIndex = 35

        Me.Label6.Text = "旋转"

        '

        'VScrollBar1

        '

        Me.VScrollBar1.LargeChange = 30

        Me.VScrollBar1.Location = New System.Drawing.Point(480, 88)

        Me.VScrollBar1.Maximum = 628

        Me.VScrollBar1.Name = "VScrollBar1"

        Me.VScrollBar1.Size = New System.Drawing.Size(24, 280)

        Me.VScrollBar1.TabIndex = 36

        '

        'Label7

        '

        Me.Label7.Location = New System.Drawing.Point(16, 40)

        Me.Label7.Name = "Label7"

        Me.Label7.Size = New System.Drawing.Size(32, 16)

        Me.Label7.TabIndex = 37

        Me.Label7.Text = "颜色"

        '

        'Label8

        '

        Me.Label8.Location = New System.Drawing.Point(136, 40)

        Me.Label8.Name = "Label8"

        Me.Label8.Size = New System.Drawing.Size(32, 16)

        Me.Label8.TabIndex = 39

        Me.Label8.Text = "宽度"

        '

        'TextBox7

        '

        Me.TextBox7.Location = New System.Drawing.Point(168, 32)

        Me.TextBox7.Name = "TextBox7"

        Me.TextBox7.Size = New System.Drawing.Size(40, 21)

        Me.TextBox7.TabIndex = 40

        Me.TextBox7.Text = "2"

        '

        'Button2

        '

        Me.Button2.Location = New System.Drawing.Point(64, 32)

        Me.Button2.Name = "Button2"

        Me.Button2.Size = New System.Drawing.Size(64, 24)

        Me.Button2.TabIndex = 43

        Me.Button2.Text = "选择"

        '

        'Form2

        '

        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)

        Me.ClientSize = New System.Drawing.Size(568, 405)

        Me.Controls.Add(Me.Button2)

        Me.Controls.Add(Me.TextBox7)

        Me.Controls.Add(Me.Label8)

        Me.Controls.Add(Me.Label7)

        Me.Controls.Add(Me.VScrollBar1)

        Me.Controls.Add(Me.Label6)

        Me.Controls.Add(Me.TextBox5)

        Me.Controls.Add(Me.Label5)

        Me.Controls.Add(Me.TextBox4)

        Me.Controls.Add(Me.Label4)

        Me.Controls.Add(Me.TextBox3)

        Me.Controls.Add(Me.Label3)

        Me.Controls.Add(Me.TextBox2)

        Me.Controls.Add(Me.Label2)

        Me.Controls.Add(Me.Label1)

        Me.Controls.Add(Me.TextBox1)

        Me.Controls.Add(Me.PictureBox1)

        Me.Controls.Add(Me.Button1)

        Me.Name = "Form2"

        Me.Text = "Form2"

        Me.ResumeLayout(False)

 

 

 

    End Sub

 

 

 

#End Region

 

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        drawit()

    End Sub

 

 

 

    Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll

        drawit()

    End Sub

    Sub drawit()

        penA.Width = CInt(TextBox7.Text)

 

 

 

        PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height)

        DrawAngle(CLng(TextBox1.Text), CLng(TextBox2.Text), PictureBox1.Image, CLng(TextBox4.Text), CLng(TextBox5.Text), CLng(TextBox3.Text), VScrollBar1.Value / 10, penA)

 

 

 

    End Sub

 

 

 

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        penA = New Pen(Color.Red, 2)

    End Sub

 

 

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        If ColorDialog1.ShowDialog() = DialogResult.OK Then

            penA.Color = ColorDialog1.Color

            Button2.BackColor = penA.Color

        End If

 

 

 

    End Sub

End Class

 

 

 



posted on 2005-11-08 08:17  a11s.net  阅读(2844)  评论(8编辑  收藏  举报