Paint Lines : Line « 2D « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
VB.Net » 2D » LineScreenshots 
Paint Lines
Paint Lines

Imports System
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Drawing.Drawing2D

Class MyFirstForm
    Inherits Form


    Public Sub Draw(ByVal g As Graphics)
        g.SmoothingMode = SmoothingMode.AntiAlias

        Dim rect As Rectangle = Me.ClientRectangle
        Dim cx As Integer = rect.Width
        Dim cy As Integer = rect.Height
        Dim scale As Single = CSng(cy/ CSng(cx)

        Dim _brush As LinearGradientBrush = New LinearGradientBrush(Me.ClientRectangle, Color.Empty, Color.Empty, 45)

        Dim blend As ColorBlend = New ColorBlend()
        blend.Colors = New Color() {Color.Red, Color.Green, Color.Blue}
        blend.Positions = New Single() {0.00.51.0}
        _brush.InterpolationColors = blend
        Dim _pen As Pen = New Pen(_brush)
        Dim As Integer
        For x = To cx Step 7
            g.DrawLine(_pen, 0, x * scale, cx - x, 0)
            g.DrawLine(_pen, 0(cx - x* scale, cx - x, cx * scale)
            g.DrawLine(_pen, cx - x, * scale, cx, (cx - x* scale)
            g.DrawLine(_pen, cx - x, cx * scale, cx, x * scale)
        Next

        Dim format As StringFormat = New StringFormat()
        format.Alignment = StringAlignment.Center
        format.LineAlignment = StringAlignment.Center

        Dim As String = "Ain't graphics cool?"
        g.DrawString(s, Me.Font, _brush, rect.X, rect.Y, format)
    End Sub

    Private Sub MyPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgsHandles MyBase.Paint
        Dim As Graphics = e.Graphics
        Draw(g)
    End Sub

    Shared Sub Main()
        Dim myform As Form = New MyFirstForm()
        Application.Run(myform)
    End Sub
End Class
           
       
Related examples in the same category
1. Draw Colorful Line and Dash LineDraw Colorful Line and Dash Line
2. Draw lines to connect rectanglesDraw lines to connect rectangles
3. Use Texture Brush to Draw a LineUse Texture Brush to Draw a Line
ww__w__.___j__av___a2_s__._c___o___m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.