Results 1 to 3 of 3

Thread: Gradient Colors Suggestions

  1. #1

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Gradient Colors Suggestions

    I'm working on a little game, and would like to have some suggestions on how to make my forms background look cool.

    What are some of the things that you guys/gals do?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Try this

    VB Code:
    1. Private Sub DiagGradient(MyForm As Form, rs As Integer, gs As Integer, bs As Integer, re As Integer, ge As Integer, be As Integer, Smooth As Boolean)
    2.     Dim ri As Integer
    3.     Dim gi As Integer
    4.     Dim bi As Integer
    5.     Dim rc As Integer
    6.     Dim bc As Integer
    7.     Dim gc As Integer
    8.     Dim x As Integer
    9.     If MyForm.WindowState = vbMinimized Then Exit Sub
    10.     MyForm.BackColor = RGB(re, ge, be)
    11.     If Smooth = True Then
    12.         MyForm.DrawStyle = 6
    13.     Else
    14.         MyForm.DrawStyle = 0
    15.     End If
    16.     If MyForm.ScaleWidth <> 255 Then
    17.         MyForm.ScaleWidth = 255
    18.     End If
    19.     If MyForm.ScaleHeight <> 255 Then
    20.         MyForm.ScaleHeight = 255
    21.     End If
    22.     MyForm.DrawWidth = 5
    23.     MyForm.Refresh
    24.     ri = (rs - re) / 255
    25.     gi = (gs - ge) / 255
    26.     bi = (bs - be) / 255
    27.     rc = rs: bc = bs: gc = gs
    28.     For x = 0 To 255
    29.     DoEvents
    30.     MyForm.Line (0, x)-(x, 0), RGB(rc, gc, bc)
    31.     rc = rc - ri
    32.     gc = gc - gi
    33.     bc = bc - bi
    34.     Next x
    35.     ri = (re - rs) / 255
    36.     gi = (ge - gs) / 255
    37.     bi = (be - bs) / 255
    38.     rc = re: bc = be: gc = ge
    39.     For x = 255 To 0 Step -1
    40.         DoEvents
    41.         MyForm.Line (255 - x, 255)-(255, 255 - x), RGB(rc, gc, bc)
    42.         rc = rc - ri
    43.         gc = gc - gi
    44.         bc = bc - bi
    45.     Next x
    46. End Sub
    47.  
    48. Private Sub Form_Resize()
    49. DiagGradient Form1, 111, 111, 222, 222, 255, 255, True
    50. End Sub

  3. #3

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160
    Thanks Hack.

    Anyone else?

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