VB课程设计:简单画笔的实现 VB课程设计留了这个作业,那个创新的填颜色部分不会,求指导。。。

VB课程设计:简单画笔的实现 VB课程设计留了这个作业,那个创新的填颜色部分不会,求指导。。。,第1张

好麻烦哟!终于作好了!

Dim Ht As Boolean

Private Type Zb

X0 As Long

Y0 As Long

End Type

Dim Cszb As Zb

Private Sub Command1_Click()

Ht = True

End Sub

Private Sub Command2_Click()

Ht = False

End Sub

Private Sub Command3_Click()

Picture1.Cls

End Sub

Private Sub Command4_Click()

Dim Ys As Integer

Ys = InputBox("请填入正整数,0:黑色,1:红色,2:黄色,3:绿色,4:蓝色,>5:白色", "设置颜色", 0)

Select Case Ys

Case 0

Picture1.ForeColor = &H0&

Case 1

Picture1.ForeColor = &HFF&

Case 2

Picture1.ForeColor = &HFFFF&

Case 3

Picture1.ForeColor = &HFF00&

Case 4

Picture1.ForeColor = &HFF0000

Case Else

Picture1.ForeColor = &HFFFFFF

End Select

End Sub

Private Sub Command5_Click()

Dim Kd As Integer

Kd = Int(InputBox("请输入线条宽度", "线条宽度", 1))

If Kd <1 Then Kd = 1

Picture1.DrawWidth = Kd

End Sub

Private Sub Command6_Click()

End

End Sub

Private Sub Form_Load()

Me.Caption = "简单画笔"

Command1.Caption = "开始画图"

Command2.Caption = "停止画图"

Command3.Caption = "画板清空"

Command4.Caption = "设置颜色"

Command5.Caption = "设置宽度"

Command6.Caption = "退出"

Picture1.AutoRedraw = True

Ht = False

Ys = 0

End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Cszb.X0 = X

Cszb.Y0 = Y

End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Ht And Button = 1 Then

Picture1.Line (Cszb.X0, Cszb.Y0)-(X, Y)

Cszb.X0 = X

Cszb.Y0 = Y

End If

End Sub

画笔,鼠标移动到哪儿就画到哪儿是吧,以下代码将鼠标移动的路径用线连接起来,形成一条不光滑曲线,和画图工具里面的画笔效果一样。

Dim canpen As Boolean

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

canpen = True '可以画线的标志

Picture1.CurrentX = X: Picture1.CurrentY = Y '设置起点

Picture1.DrawMode = 13 '画图方式

End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 1 And canpen = True Then

Picture1.Line -(X, Y), Picture1.ForeColor '画线

End If

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/7948471.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-11
下一篇 2023-04-11

发表评论

登录后才能评论

评论列表(0条)

保存