当前位置: 源码素材网 » VB教程 » 详情页

绘制抛物线的VB代码

  •   时间:2019-03-19
  • 概述:抛物线

Vb绘制一个具有动画效果的抛物线,用For循环绘点,使其按抛物线规律变化。步长值很小,使之形成动画效果:

VERSION 5.00
Begin VB.Form Form1
   Caption         =   "绘制抛物线"
   ClientHeight    =   4650
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7005
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   4650
   ScaleWidth      =   7005
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command2
      Caption         =   "关闭"
      Height          =   450
      Left            =   5745
      TabIndex        =   2
      Top             =   4095
      Width           =   1170
   End
   Begin VB.PictureBox Picture1
      Height          =   3945
      Left            =   45
      ScaleHeight     =   3885
      ScaleWidth      =   6810
      TabIndex        =   1
      Top             =   60
      Width           =   6870
   End
   Begin VB.CommandButton Command1
      Caption         =   "绘制"
      Height          =   450
      Left            =   4110
      TabIndex        =   0
      Top             =   4095
      Width           =   1170
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const PI = 3.14159
Dim a
Private Sub Command1_Click()
    Picture1.Cls    '清空
    Picture1.ScaleMode = 3    '设置为像素
    Picture1.Scale (-20, 30)-(20, -10)    '坐标原点在Picture1中心
    Picture1.DrawWidth = 1    '设置绘线宽度
    Picture1.Line (-20, 0)-(20, 0), RGB(0, 0, 255)    '绘制X轴
    Picture1.Line (0, 30)-(0, -10), RGB(0, 0, 255)    '绘制Y轴
    '指定位置显示原点O
    Picture1.CurrentX = 1
    Picture1.CurrentY = -1
    Picture1.DrawWidth = 2 '重设绘线宽度
    '用For循环绘点,使其按抛物线规律变化。步长值很小,使之形成动画效果
    For a = -15 To 15 Step PI / 6000
        Picture1.PSet (a, a * a / 8), RGB(255, 0, 0)
    Next a
End Sub
Private Sub Command2_Click()
    Unload Me
End Sub

    相关内容:

    相关声明:

      若“绘制抛物线的VB代码”有损您的权益,请告之我们删除内容。
      部分文章来源于网络,版权归原作者所有。