VB 2008 Tutorial - GDI+ Multi colored Text Animation Effect

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
5 posts Page 1 of 1
Contributors
User avatar
tvs praveen
Top Poster
Top Poster
Posts: 205
Joined: Tue Dec 08, 2009 6:20 am

Hi, Now i`m gonna show how to paint GDI+ Multi colored Text Animation Effect in VB.NET, I made this tutorial too simple which first time users of VB.NET also can understand this tutorial!

Now add 1 PictureBox and 1 Timer

Note: PictureBox is using to paint

In Properties of Timer make Enabled into True

Then add this Imports above Public Class Form1
Code: Select all
Imports System.Drawing.Drawing2D
Then add this code below Public Class Form1
Code: Select all
    Inherits System.Windows.Forms.Form
    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Private components As System.ComponentModel.IContainer
    Friend WithEvents picCanvas As System.Windows.Forms.PictureBox
    Friend WithEvents tmrRotate As System.Windows.Forms.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.picCanvas = New System.Windows.Forms.PictureBox
        Me.tmrRotate = New System.Windows.Forms.Timer(Me.components)
        CType(Me.picCanvas, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'picCanvas
        '
        Me.picCanvas.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.picCanvas.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.picCanvas.Location = New System.Drawing.Point(8, 8)
        Me.picCanvas.Name = "picCanvas1"
        Me.picCanvas.Size = New System.Drawing.Size(600, 162)
        Me.picCanvas.TabIndex = 0
        Me.picCanvas.TabStop = False
        '
        'tmrRotate
        '
        Me.tmrRotate.Enabled = True
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(32, 77)
        Me.ClientSize = New System.Drawing.Size(620, 182)
        Me.Controls.Add(Me.picCanvas)
        Me.Font = New System.Drawing.Font("Times New Roman", 50.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Name = "Form1"
        CType(Me.picCanvas, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
    End Sub
    Private m_Middle As Single = 0
    Private m_Delta As Single = 0.1
Then add this code into PictureBox`s Paint in Events
Code: Select all
  ' Make the gradient brush.
        Dim br As New LinearGradientBrush(New Point(0, 0), New Point(Me.ClientSize.Width, 0), Color.Red, Color.Blue)
        Dim color_blend As New ColorBlend
        color_blend.Colors = New Color() {Color.Red, Color.Blue, Color.SpringGreen}
        color_blend.Positions = New Single() {0, m_Middle, 1}
        br.InterpolationColors = color_blend
        ' Fill some text with it.
        Dim string_format As New StringFormat
        string_format.Alignment = StringAlignment.Center
        string_format.LineAlignment = StringAlignment.Center
        Dim graphics_path As New GraphicsPath
        graphics_path.AddString("Tvs Praveen", _
            Me.Font.FontFamily, _
            CInt(FontStyle.Bold), Me.Font.Size, _
            picCanvas.ClientRectangle, _
            string_format)
        e.Graphics.FillPath(br, graphics_path)
        br.Dispose()
        ' Adjust the gradient's midpoint.
        m_Middle += m_Delta
        If (m_Middle > 1) OrElse (m_Middle < 0) Then m_Delta = -m_Delta
Double click Timer and add this code into it
Code: Select all
PictureBox1.Invalidate()
Then you get some errors in Error List, Then click any error from ErrorList and remove all the codes from Form1 Designer

Now debug, Here your`s GDI+ Gradient Colored Background Effect is ready to use!, Its glowy and shiny with gradient colored background animation!

You can change text, font styles, size, location and sizes in code Paint in Events of PictureBox

Figure 1 [Screenshot of GDI+ Multi colored Text Animation Effect]

Image


*******************Thanks for reading my tutorial, I think this Tutorial will be most helpful to you!*******************

If you want any custom tutorial for you or you need any help in VS.NET, VB.NET, Software Coding, Designing and much more any help in Computer stuffs just ask me

Mostly i will help everyone in coding and design stuffs in on Computer

- Best regards hehaho;

- Tvs Praveen wahooo;

- Thanks CodeNStuff! for this amazing Website cooll;
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

I have an idea for you projects... Can't you add textboxes to set the font size and the font type and the font colours and the font location? It would be much better for everyone to use your application! And maybe you can develop a Desktop application like the website "cooltext.com". I really love your tutorials!

Thank you!
Image
User avatar
tvs praveen
Top Poster
Top Poster
Posts: 205
Joined: Tue Dec 08, 2009 6:20 am

Usman55 wrote:
I have an idea for you projects... Can't you add textboxes to set the font size and the font type and the font colours and the font location? It would be much better for everyone to use your application! And maybe you can develop a Desktop application like the website "cooltext.com". I really love your tutorials!

Thank you!
Thank you a lot, Yes i can do like in your request, I will do like you told on all of my upcoming and in exiting tutorials as soon as possible :D
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Hello TVS Praveen,

I am very glad to learn that you have liked my idea and have decided to work on it. I just love your tutorials. They are just awesome!

Thank you.
Image
User avatar
tvs praveen
Top Poster
Top Poster
Posts: 205
Joined: Tue Dec 08, 2009 6:20 am

Usman55 wrote:
Hello TVS Praveen,

I am very glad to learn that you have liked my idea and have decided to work on it. I just love your tutorials. They are just awesome!

Thank you.
Yes, Now i`m working on making 3D text! :D
5 posts Page 1 of 1
Return to “Tutorials”