Results 1 to 5 of 5

Thread: Another "Anyone know how to do this?"

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263

    Post

    What would be the code to make a gradient of:
    Black -> AnyColor -> White
    ?

  2. #2
    Lively Member
    Join Date
    Nov 1999
    Posts
    64

    Post

    r=0
    g=0
    b=0
    For n = 1 to 255
    r = r + 1
    g = g + 1
    b = b + 1
    next n
    'this will do a fade, just use the rgb function to change the color of what u want to change.

  3. #3
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    I'm not that good with english.
    what is a gradient??
    If you mean a fading from one color to another, here's some code to fade the background of a form that might help you along the way
    Code:
    'A background that fade's from blue to black
    Private Sub Form_Paint()
    Dim lY As Long
    Dim lScaleHeight As Long
    Dim lScaleWidth As Long
    
    ScaleMode = vbPixels
    lScaleHeight = ScaleHeight
    lScaleWidth = ScaleWidth
    DrawStyle = vbInvisible
    FillStyle = vbFSSolid
    
    For lY = 0 To lScaleHeight
        FillColor = RGB(0, 0, 255 - (lY * 255) \ lScaleHeight)
        Line (-1, lY - 1)-(lScaleWidth, lY + 1), , B
    Next lY
    
    'rgb(0,0,255 - (lY...) ' blue to black
    'rgb(0,100,255 - (lY...) 'blue to green
    'rgb(255,0,255 - (lY...) 'lightpink to red
    'rgb(255,255,255 - (lY...)'white to yellow
    'rgb(0,255,255 - (lY...) 'white to green
    'rgb(255,100,255 - (lY...)'light pink to orange
    
    'place the "255-(lY*255)\ lScaleHeight at the "R" or "G" to make 
    'it fade from another color
    
    End Sub
    Wanna be helpful

    ------------------
    On Error Goto Bed :0)
    [email protected]



  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263

    Post

    Well, yeah, I already know how to create my own gradients, thanks, I just want to know how to do the way I originally asked

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Post

    This does what you want for red. You can use this as a template to do ‘any 1(R or G or B) color’. With a little Work you could make it work for any (R and G and B) color. You’d have to define the original ‘any’ color using RGB, create it by incrementing from RGB(0,0,0),and then when that color’s achieved increment all the values to RGB(255,255,255) .Simple enough?
    Private Sub Form_Load()
    Dim Red As Integer
    AutoRedraw = True
    For Red = 1 To 255
    'increment red
    R = R + 1
    'use Red to create new x position
    'then draw new colored line
    xpos = Red * 10
    Line (xpos, 0)-(xpos, 8000), RGB(R, B, G)
    'If Red = 255 then Red is all done
    'so increment Green + Blue untill 255
    'RBG(255,255,255) = white
    If R >= 255 Then
    For G = 1 To 255
    G = G + 1
    B = G
    'add new and last position to
    xpos = (G * 10) + 2550
    Line (xpos, 0)-(xpos, 8000), RGB(R, B,G)
    Next
    End If
    Next
    End Sub



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