VB 2008 Tutorial - GDI+ Text Animation

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.
6 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 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;
Last edited by tvs praveen on Sat Jan 23, 2010 5:59 am, edited 1 time in total.
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

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

Usman55 wrote:
Cool!

Thanks Usman55! :D
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

This is very good! Im loving all of these !
Image
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

GDI is more powerful then I thought... Seriously you'll have success by posting GDI tutorials.
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

I agree with Nery :D
Image
6 posts Page 1 of 1
Return to “Tutorials”