Results 1 to 38 of 38

Thread: Gradient Text <<resolved>>

  1. #1
    j2k
    Guest

    Gradient Text <<resolved>>

    Hi, is it possible to create gradient text? Similar to:



    Apologies for the bad quality of the image.

  2. #2
    Junior Member
    Join Date
    Oct 2001
    Posts
    20
    Would it be possible to create gradient text in VB? I would like to know also.

  3. #3
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Which one? The one which is in the image or the one which nishantp has in his post?
    Baaaaaaaaah

  4. #4
    j2k
    Guest
    In VB. Like the image I posted. Vertical gradient in VB.

  5. #5
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    I would like to know how you did that in the forums.

  6. #6
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    I have no idea how to do it in VB, but here is the forum way:



    Itsnotreallyagradient,everycharisitsowncolor.Itjustappearsthatway.
    You just proved that sig advertisements work.

  7. #7
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    Oh and BTW - about the VB way, making a form gradient is rather simple (i have written my own code for this). But for text i can see no way other than doing the same as the VB-World tool does (see my above post), and have each character a different color. But that wont work for large characters.
    You just proved that sig advertisements work.

  8. #8
    Junior Member
    Join Date
    Oct 2001
    Posts
    20
    Originally posted by nishantp
    Oh and BTW - about the VB way, making a form gradient is rather simple (i have written my own code for this). But for text i can see no way other than doing the same as the VB-World tool does (see my above post), and have each character a different color. But that wont work for large characters.
    How would you go about at making your form gradient?

  9. #9
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Baaaaaaaaah

  10. #10
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Here is the very basic gradiants text in a richtextbox:

    VB Code:
    1. rtf1.Text = "This is  my text that"
    2. For x = 0 To Len(rtf1.Text) - 1
    3. rtf1.SelStart = x
    4. rtf1.SelLength = 1
    5. rtf1.SelColor = RGB(0, 0, x * 10)
    6. Next x
    Baaaaaaaaah

  11. #11
    j2k
    Guest
    Hmm, that is for a horizontal gradient I need vertical gradient.

    Why do I get a funny feeling this is not possible?

  12. #12
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I have been always thinking of doing that "Vertical" gradiants but I have no clue how to do that.

    The biggest problem is having more than one colour on a character.
    Baaaaaaaaah

  13. #13
    Originally posted by j2k
    Hmm, that is for a horizontal gradient I need vertical gradient.

    Why do I get a funny feeling this is not possible?
    Conceptually, here's how I see it: make a mask using text and fill a picturebox. Does PSC have anything?

  14. #14
    j2k
    Guest
    Filburt1, don't suppose you could throw together an example project of your ramblings just then could you please?

    What is PSC? How do I use masks?

  15. #15
    It was just a theory, I wouldn't know where to start.

  16. #16
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    Originally posted by j2k
    Filburt1, don't suppose you could throw together an example project of your ramblings just then could you please?

    What is PSC? How do I use masks?
    PSC=PlanetSourceCode.com

  17. #17
    j2k
    Guest
    Originally posted by filburt1
    It was just a theory, I wouldn't know where to start.
    That makes two of us..

  18. #18
    j2k
    Guest
    Originally posted by eiSecure
    PSC=PlanetSourceCode.com
    <smacks head!> Of course! So obvious!


    BTW people - eiSecure's forum really is COOL! Have you checked it out recently??!

  19. #19
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    first person to 30 referrals gets free copy of Secure-It! 2002 & all future versions & free support.

  20. #20
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I will start thinking about writting some code on it.

    Would not that work:

    You create a gradiant coloured object, and then paste the colours from that object on a picturebox (but they will only be pasted where you find a specific colour - the text forecolour).
    Baaaaaaaaah

  21. #21
    j2k
    Guest
    Hmm. Interesting theory. Could you please give it a go?

    Many thanks!!

  22. #22
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I will start working on it now.
    Baaaaaaaaah

  23. #23
    j2k
    Guest
    Thank you my friend

  24. #24
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Originally posted by eiSecure
    first person to 30 referrals gets free copy of Secure-It! 2002 & all future versions & free support.
    Please describe your program
    Baaaaaaaaah

  25. #25
    j2k
    Guest
    Originally posted by abdul
    I will start working on it now.
    Hi.. Have you gotten anywhere with it?

  26. #26
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Not totally but I'll keep trying
    Baaaaaaaaah

  27. #27
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    The progress

    Just to show to the picture of what is going on I think that is what you want.
    Baaaaaaaaah

  28. #28
    j2k
    Guest

    Re: The progress

    Originally posted by abdul
    Just to show to the picture of what is going on I think that is what you want.
    .

    That's great Any chance of the gradient going down vertically instead of horizontally? It's just what I'm after - thanks

  29. #29
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    There was no problem making it vertical. I just had to change the way it coloured the font.
    I will post the other picture after some mintues
    Baaaaaaaaah

  30. #30
    j2k
    Guest
    Excellent!! Any chance of the source please?

  31. #31
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    No Problem

    The source code is not that long (a few lines). I'll post the source code after I go home
    Baaaaaaaaah

  32. #32
    j2k
    Guest
    Great - thanks When do you go home (if you don't mind my asking), as I am in UK an it is 18:05 now.

  33. #33
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    It's 1:15 and I'll will go at 3:20

    Anyway, here is the code for the basic one (no specific function to do that yet):

    VB Code:
    1. 'First put a picture box on the form and make the font face large enough
    2. Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
    3. Private Declare Function GetTextMetrics Lib "gdi32" Alias "GetTextMetricsA" (ByVal hdc As Long, lpMetrics As TEXTMETRIC) As Long
    4. Private Type TEXTMETRIC
    5.         tmHeight As Long
    6.         tmAscent As Long
    7.         tmDescent As Long
    8.         tmInternalLeading As Long
    9.         tmExternalLeading As Long
    10.         tmAveCharWidth As Long
    11.         tmMaxCharWidth As Long
    12.         tmWeight As Long
    13.         tmOverhang As Long
    14.         tmDigitizedAspectX As Long
    15.         tmDigitizedAspectY As Long
    16.         tmFirstChar As Byte
    17.         tmLastChar As Byte
    18.         tmDefaultChar As Byte
    19.         tmBreakChar As Byte
    20.         tmItalic As Byte
    21.         tmUnderlined As Byte
    22.         tmStruckOut As Byte
    23.         tmPitchAndFamily As Byte
    24.         tmCharSet As Byte
    25. End Type
    26. Dim tm As TEXTMETRIC
    27.  
    28. Private Sub Command1_Click()
    29. GetTextMetrics Picture1.hdc, tm
    30. For tx = 1 To Len("MY PICTURE") * tm.tmMaxCharWidth
    31. For ty = 1 To tm.tmHeight
    32. If Picture1.Point(tx, ty) = vbBlack Then
    33. SetPixelV Picture1.hdc, tx, ty, RGB(20, ty * 2, 0)
    34. End If
    35. Next
    36. Next
    37. End Sub
    38.  
    39. Private Sub Form_Load()
    40. Picture1.AutoRedraw = True
    41. Picture1.ScaleMode = 3
    42. Picture1.Print "MY PICTURE"
    43. End Sub

    Here is the picture again for vertical gradiants
    Baaaaaaaaah

  34. #34
    j2k
    Guest
    Thanks

    Is it possible to change the gradient colour from green? I want the top to be dark red, to turn to orange.

    TIA.

  35. #35
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    That is why I said it is not finished.
    I am now going to write a function that will take the starting colous, ending colour, and the type of gradiants the user wants(vertical or horizontal)
    Baaaaaaaaah

  36. #36
    j2k
    Guest
    Great stuff - thanks again

  37. #37
    j2k
    Guest
    Please post source here when it's done

    TIA

  38. #38
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Your Welcome
    This space for rent...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width