VB 如何在picture中用line方法连续画线 10
问题简单,请有意者加本人QQ942770373,本人将直接发代码。谢谢!急啊Picture1.Line(oldx,oldy)-(x0,y0)'擦除上一次绘制的直线Pict...
问题简单,请有意者加本人QQ942770373 ,本人将直接发代码。谢谢!急啊
Picture1.Line (oldx, oldy)-(x0, y0) '擦除上一次绘制的直线
Picture1.Line (oldx, oldy)-(X, Y)
StatusBar1.Panels(1) = "长度:" & length(oldx, oldy, X, Y)
StatusBar1.Panels(4) = "起:X:" & Round(oldx, 1) & ",Y:" & _
Round(oldy, 1) & " 终:X:" & Round(X, 1) & ",Y:" & Round(Y, 1)
希望大家看看这个! 展开
Picture1.Line (oldx, oldy)-(x0, y0) '擦除上一次绘制的直线
Picture1.Line (oldx, oldy)-(X, Y)
StatusBar1.Panels(1) = "长度:" & length(oldx, oldy, X, Y)
StatusBar1.Panels(4) = "起:X:" & Round(oldx, 1) & ",Y:" & _
Round(oldy, 1) & " 终:X:" & Round(X, 1) & ",Y:" & Round(Y, 1)
希望大家看看这个! 展开
3个回答
展开全部
VB可用object.Line - (x2, y2)写法实现在对象上绘制连续折线。
Line 方法,在对象上画直线和矩形。
以下是具体实现绘制曲线的代码:
Option Explicit
Const PI = 3.14159265432
Private Sub Command1_Click()
Picture1.Scale (-2 * PI, 1)-(2 * PI, -1) '建立坐标系
Dim I As Single
Picture1.CurrentX = -2 * PI '建立当前坐标
Picture1.CurrentY = 0
For I = -2 * PI To 2 * PI Step 0.01
Picture1.Line -(I, Cos(3 * I) * Sin(5 * I)), vbRed '绘制曲线
Next
End Sub
运行效果:
展开全部
在一个按扭下添加如下代码,每点击一次就连接前次画一条直线
Static x As Integer, y As Integer
Dim x1 As Integer
Dim y1 As Integer
x1 = Int(Picture1.Width * Rnd())
y1 = Int(Picture1.Height * Rnd())
Picture1.Line (x, y)-(x1, y1)
x = x1
y = y1
Static x As Integer, y As Integer
Dim x1 As Integer
Dim y1 As Integer
x1 = Int(Picture1.Width * Rnd())
y1 = Int(Picture1.Height * Rnd())
Picture1.Line (x, y)-(x1, y1)
x = x1
y = y1
追问
能不能加我的QQ,急事啊
追答
Picture1.Line -(Int(Picture1.Width * Rnd()), Int(Picture1.Height * Rnd()))
这样就可以从前一条线段的 x2, y2 可以画出连续折线。
qq:504526542
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要点是:
Picture1.Line (x1, y1)-(x2, y2)
只要 下一条线段的 x1, y1 等于 前一条线段的 x2, y2 就可以画出连续折线。
Picture1.Line (x1, y1)-(x2, y2)
只要 下一条线段的 x1, y1 等于 前一条线段的 x2, y2 就可以画出连续折线。
追问
能不能加我的QQ,急事啊
追答
先试试这个:
Option Explicit
Dim oldX1 As Single, oldY1 As Single, oldX2 As Single, oldY2 As Single
Dim X0 As Single, Y0 As Single
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
X0 = X
Y0 = Y
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Line (oldX1, oldY1)-(oldX2, oldY2), Me.Picture1.BackColor
Picture1.Line (X0, Y0)-(X, Y)
oldX1 = X0
oldY1 = Y0
oldX2 = X
oldY2 = Y
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询