Page 1 of 1

VB 2008 Tutorial - GDI+ Text Animation

Posted: Sat Jan 23, 2010 5:21 am
by tvs praveen
Hi, Now i will explain shortly about GDI+, GDI+ is the way of creating any graphics like Text or objects using GDI+ way of coding

Now i gonna show you how to make exclusive GDI+ Text Animation with these simple codes

You can also change Text Font, Size, Where to display and Draw Location in codes

Insert 1 Timer and 1 PictureBox, Note: I used PictureBox to display the GDI+ Text Animation

And i used Timer as main control to draw GDI+ Text Animation

Okay then now make PictureBox size too larger to display the GDI+ Text Animation, Note: You can adjust the Text Font, Font Size, Where to Draw, Draw Location and Color in the Timer`s code

Now first add these Imports top of the Public Class Form1
Code: Select all
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text
Then insert this below Public Class Form1
Code: Select all
Const TextTimerInterval As Integer = 15 ' In milliseconds
    Protected currentGradientShift As Integer = 10
    Protected gradiantStep As Integer = 5
Now double click Timer and insert this code into it
Code: Select all
Dim grfx As Graphics = PictureBox1.CreateGraphics()
        ' Set the font type, text, and determine its size.
        Dim font As New Font("Microsoft Sans Serif", 66, _
            FontStyle.Bold, GraphicsUnit.Point)
        Dim strText As String = "Tvs Praveen"
        Dim sizfText As New SizeF(grfx.MeasureString(strText, font))
        ' Set the point at which the text will be drawn: centered
        ' in the client area.
        Dim ptfTextStart As New PointF( _
            CSng(ClientSize.Width - sizfText.Width) / 2, _
            CSng(ClientSize.Height - sizfText.Height) / 2)
        ' Set the gradient start and end point, the latter being adjusted
        ' by a changing value to give the animation affect.
        Dim ptfGradientStart As New PointF(0, 0)
        Dim ptfGradientEnd As New PointF(currentGradientShift, 200)
        ' Instantiate the brush used for drawing the text.
        Dim grBrush As New LinearGradientBrush(ptfGradientStart, _
            ptfGradientEnd, Color.Red, BackColor)
        ' Draw the text centered on the client area.
        grfx.DrawString(strText, font, grBrush, ptfTextStart)
        grfx.Dispose()
        ' Shift the gradient, reversing it when it gets to a certain value.
        currentGradientShift += gradiantStep
        If currentGradientShift = 500 Then
            gradiantStep = -5
        ElseIf currentGradientShift = -50 Then
            gradiantStep = 5
End If
After you done everything in the coding then debug, You get your 3D GDI+ Text Animation! wahooo;

Figure 1 Screenshot [Screenshot of GDI+ Text Animation after debugging]

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;

Re: VB 2008 Tutorial - GDI+ Text Animation

Posted: Sat Jan 23, 2010 5:40 am
by Usman55
Cool!

Re: VB 2008 Tutorial - GDI+ Text Animation

Posted: Sat Jan 23, 2010 5:45 am
by tvs praveen
Usman55 wrote:
Cool!

Thanks Usman55! :D

Re: VB 2008 Tutorial - GDI+ Text Animation

Posted: Sat Jan 23, 2010 1:21 pm
by Lewis
This is very good! Im loving all of these !

Re: VB 2008 Tutorial - GDI+ Text Animation

Posted: Sat Jan 23, 2010 1:22 pm
by Nery
GDI is more powerful then I thought... Seriously you'll have success by posting GDI tutorials.

Re: VB 2008 Tutorial - GDI+ Text Animation

Posted: Sat Jan 23, 2010 1:43 pm
by Lewis
I agree with Nery :D