CodeItBetter Programming Another VB Programming Blog

How to Draw 3D Gradient text on form

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'Graphics - How to Draw 3D Gradient text on form

Option Explicit
 
'Add two Command Buttons to your form. The first one is to draw the text, and the second one is to erase it.

Private Sub Command1_Click()
    Draw3d "http://codeitbetter.com", 20, 8, "Courier New", 20, 20, 0, 0, 0, 250, 0, 0
End Sub
 
Private Sub Command2_Click()
    Delete3d "http://codeitbetter.com", 20, 8, "Courier New", 20, 20
End Sub
 
Private Sub Draw3d(Text As String, FontSize, TextWidth, FontType, X, Y, FromR, FromG, FromB, ToR, ToG, ToB)
    With Me
        .AutoRedraw = True
        .FontSize = FontSize
        .Font = FontType
        .ScaleMode = 3
    End With
    Dim I As Integer, FactorR As Integer, FactorG As Integer, FactorB As Integer
    FactorR = (ToR - FromR) / TextWidth
    FactorG = (ToG - FromG) / TextWidth
    FactorB = (ToB - FromB) / TextWidth
    For I = 0 To TextWidth
        CurrentX = I + X
        CurrentY = I + Y
        ForeColor = RGB(FromR, FromG, FromB)
        FromR = FromR + FactorR
        FromG = FromG + FactorG
        FromB = FromB + FactorB
        Me.Print Text
    Next I
End Sub
 
Private Sub Delete3d(Text As String, FontSize, TextWidth, FontType, X, Y)
    With Me
        .AutoRedraw = True
        .FontSize = FontSize
        .Font = FontType
        .ScaleMode = 3
    End With
    Dim I As Integer
    For I = 0 To TextWidth
        CurrentX = I + X
        CurrentY = I + Y
        ForeColor = Me.BackColor
        Me.Print Text
    Next I
End Sub
Filed under: Graphics Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.