根據(jù)時間變化繪制的,即時的,或許可以用chart圖表控件,百度會出現(xiàn)微軟網(wǎng)站的資料。
創(chuàng)新互聯(lián)公司專注于寬城網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供寬城營銷型網(wǎng)站建設(shè),寬城網(wǎng)站制作、寬城網(wǎng)頁設(shè)計、寬城網(wǎng)站官網(wǎng)定制、小程序定制開發(fā)服務(wù),打造寬城網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供寬城網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
sin曲線永遠(yuǎn)是哪個樣子,你是怎么變化?一般的移動,可以用offset控制向左平移,右邊則增加點,看上去應(yīng)該是在移動
Dim Points1(30) As Point
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer1.Interval = 200
For i = 0 To 30
Points1(i) = New Point(i * 45, Math.Sin(i) * (PictureBox1.Height - 50) / 9)
Points1(i).Offset(-450, Math.Abs(Points1(i).Y - (PictureBox1.Height - 50) / 9) * 3.55 + 43)
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static j As Long
j = j + 1
PictureBox1.Image = x_y(PictureBox1, j)
End Sub
Private Function x_y(ByVal pic As PictureBox, ByVal x As Long) As Bitmap
Dim b As New Bitmap(pic.Width, pic.Height)
Dim g As Graphics = Graphics.FromImage(b)
Dim c
Dim j
g.Clear(Color.YellowGreen)
Dim p As New Pen(Color.WhiteSmoke)
p.EndCap = Drawing2D.LineCap.ArrowAnchor
g.DrawLine(p, 20, pic.Height - 20, 20, 10)
g.DrawLine(p, 20, pic.Height - 20, pic.Width - 20, pic.Height - 20)
Dim i As Double
Dim bs As New SolidBrush(Color.Red)
Dim po As New Point
g.DrawString(-2, Me.Font, bs, 12, pic.Height - 18)
po.X = 0
po.Y = pic.Height - 45
For i = -1.6 To 4 Step 0.4
g.DrawString(Math.Round(i, 1), Me.Font, bs, po.X, po.Y)
g.DrawLine(p, po.X + 18, po.Y + 5, po.X + 20, po.Y + 5)
Dim p1 As New Pen(Color.Blue)
p1.DashStyle = Drawing2D.DashStyle.Dash
g.DrawLine(p1, po.X + 28, po.Y + 5, pic.Width - 20, po.Y + 5)
po.Y -= (pic.Height - 50) / 9
Next
po.X = 20
po.Y = pic.Height - 20
For c = 0 To 14400 Step 1200
If (c / 1200) 0 Then
g.DrawString((c / 1200) + x, Me.Font, bs, po.X - j, po.Y + 5)
End If
g.DrawLine(p, po.X, po.Y + 2, po.X, po.Y)
po.X += (pic.Width - 50) / 12
Next
For i = 0 To Points1.Count - 1
Points1(i).Offset(45, 0)
Next
If x Mod 6 = 0 Then
For i = 0 To Points1.Count - 1
Points1(i).Offset(-270, 0)
Next
End If
g.DrawCurve(Pens.Red, Points1)
'For i = 0 To Points1.Count - 1
'g.DrawString(Math.Sin(i), Me.Font, Brushes.Red, Points1(i))
'Next
Return b
End Function
為什么我的不是?
Dim?pi
pi?=?3.1415926
Dim?a
a?=?30
Text1.Text?=?Sin(a?*?pi?/?180)
VB系統(tǒng)的坐標(biāo)原點在左上角,X軸的正方向是水平向右,而Y軸的正方向是垂直向下。所以,要繪制三角函數(shù)的曲線,自己可以通過改變點坐標(biāo)的方法來實現(xiàn),當(dāng)然,VB.NET提供了相應(yīng)的方法可以來實現(xiàn)坐標(biāo)變換,也可以通過VB.Net的Graphics類提供的平移、旋轉(zhuǎn)等轉(zhuǎn)換來實現(xiàn)。
下面是我通過自己變換實現(xiàn)的示例,提供參考;我的環(huán)境是VB.NET 2010
Imports System.Math
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
? '1,獲得一個Graphics對象
? Dim MyGraphics As Graphics
? MyGraphics = PictureBox1.CreateGraphics
? '2,定義一個Pen對象,用于繪制圖形(輪廓線)
? Dim MyPen As New Pen(Color.Black, 1)
? '3,定義一個Brush對象,用于填充圖形(如果需要填充的話)
? Dim MyBrush As New SolidBrush(Color.Orange)
? MyGraphics.DrawLine(MyPen, 0, 200, 700, 200)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
? '1,獲得一個Graphics對象
? Dim MyGraphics As Graphics
? MyGraphics = PictureBox1.CreateGraphics
? '2,定義一個Pen對象,用于繪制圖形(輪廓線)
? Dim MyPen As New Pen(Color.Black, 1)
? '3,定義一個Brush對象,用于填充圖形(如果需要填充的話)
? Dim MyBrush As New SolidBrush(Color.Orange)
? '聲明橫向和縱向比例變量
? Dim Heng As Integer = 20
? Dim Zong As Integer = 50
? '先獲得正弦值,保存到點坐標(biāo)數(shù)組
? Dim MyPoints(700) As Point
? Dim i As Integer
? For i = 0 To 700
? ? ? MyPoints(i) = New Point(i * Heng, 200 + Sin(i) * Zong)
? Next
? '采用繪制光滑線連接點的方式繪制曲線
? MyGraphics.DrawCurve(MyPen, MyPoints)
End Sub
End Class
顯示的效果圖:
新聞標(biāo)題:vb.netsin的簡單介紹
文章網(wǎng)址:http://jinyejixie.com/article38/dodhjsp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、網(wǎng)頁設(shè)計公司、關(guān)鍵詞優(yōu)化、全網(wǎng)營銷推廣、營銷型網(wǎng)站建設(shè)、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)