Главная » Статьи » Програмування » Visual Basic (vb) | [ Добавить статью ] |
Прогсто програма(код для VB) яка малює лінії по певним правилам
Imports System.Drawing.Drawing2D Public Class графика Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Start() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Static N As Double Dim xx As Double = 380 Dim yy As Double = 390 Dim R As Double = TextBox4.Text + TrackBar2.Value N = N + 0.03 Dim g As Graphics = CreateGraphics() g.Clear(BackColor) Dim i As Double For i = 0 To TextBox2.Text + TrackBar1.Value Step TextBox3.Text + TrackBar4.Value Dim T As Double T = i * Math.PI / TextBox1.Text + TrackBar3.Value Dim x As Double x = R * System.Math.Cos(T) Dim y As Double y = R * System.Math.Sin(T) Dim x2 As Double x2 = R * System.Math.Cos(N * T) Dim y2 As Double y2 = R * System.Math.Sin(N * T) g.DrawLine(Pens.Green, CInt(x + xx), CInt(y + yy), CInt(x2 + xx), CInt(y2 + yy)) Next i End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Timer1.Stop() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim bm As New Bitmap(CInt(Me.ClientSize.Width / 5), CInt(Me.ClientSize.Height / 5)) Dim pth As New GraphicsPath pth.AddString("DEN-SHP", New FontFamily("Tahoma"), CInt(FontStyle.Bold), 73, New Point(0, 0), StringFormat.GenericTypographic) Dim g As Graphics = Graphics.FromImage(bm) Dim mx As Matrix mx = New Matrix(1.0F / 5, 0, 0, 1.0F / 5, -(1.0F / 5), -(1.0F / 5)) g.SmoothingMode = SmoothingMode.AntiAlias g.Transform = mx Dim p As New Pen(Color.Blue, 5) g.DrawPath(p, pth) g.FillPath(Brushes.Blue, pth) g.Dispose() e.Graphics.SmoothingMode = SmoothingMode.AntiAlias e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic e.Graphics.DrawImage(bm, ClientRectangle, 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel) e.Graphics.FillPath(Brushes.Black, pth) pth.Dispose() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox3.Text = 1 TextBox1.Text = 100 TextBox2.Text = 20 TextBox4.Text = 200 End Sub Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll TrackBar1.SetRange(minValue:=0, maxValue:=1000) Label6.Text = TrackBar1.Value End Sub Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll TrackBar2.SetRange(minValue:=0, maxValue:=300) Label7.Text = TrackBar2.Value End Sub Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll TrackBar3.SetRange(minValue:=0, maxValue:=100) Label8.Text = TrackBar3.Value End Sub Private Sub TrackBar4_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar4.Scroll TrackBar4.SetRange(minValue:=0, maxValue:=5) Label9.Text = TrackBar4.Value End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show("DEN-SHP") End Sub End Class | |
Просмотров: 711 | |
Всего комментариев: 0 | |