如何在Visual Studio中使用VB.net语言绘制星星 [英] How to Draw a star using VB.net language in Visual Studio
本文介绍了如何在Visual Studio中使用VB.net语言绘制星星的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请使用Visual Studio程序在此处键入代码,并在上面加上星星色
Please type the code here using visual studio program and put a color that star too
推荐答案
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim StarObject As Graphics = e.Graphics
Dim i As Integer
Dim random As Random = New Random()
Dim brush As SolidBrush = New SolidBrush(Color.CornflowerBlue)
' x and y points of the path
Dim xPoints As Integer() = {55, 67, 109, 73, 83, 55, 27, 37, 1, 43}
Dim yPoints As Integer() = {0, 36, 36, 54, 96, 72, 96, 54, 36, 36}
' create graphics path for star
Dim star As GraphicsPath = New GraphicsPath()
' translate the origin to (100, 100)
StarObject.TranslateTransform(100, 100)
' create star from series of points
For i = 0 To 8 Step 2
star.AddLine(xPoints(i), yPoints(i), xPoints(i + 1), yPoints(i + 1))
Next
' close the shape
star.CloseFigure()
StarObject.FillPath(brush, star)
End Sub
End Class
这篇关于如何在Visual Studio中使用VB.net语言绘制星星的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文