Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleMake an elliptical color gradient
Keywordsellipse, elliptical, gradient, color
CategoriesGraphics
 

Subroutine ShadeForm begins by setting the form's background color to the color that should be displayed on the outside edge of the gradient. It then draws a series of concentric ellipses starting with the outer ones and moving in. Each is filled with the next color in the gradient.

 
' Fill the form with an elliptical gradient.
Private Sub ShadeForm()
Const COLOR_OUTER = 64
Const COLOR_INNER = 255

Dim cx As Single
Dim cy As Single
Dim r As Single
Dim i As Single
Dim clr As Single
Dim dclr As Single

    Cls
    ScaleMode = vbPixels
    cx = ScaleWidth / 2
    cy = ScaleHeight / 2
    BackColor = RGB(0, 0, COLOR_OUTER)

    If cx > cy Then
        r = cx
    Else
        r = cy
    End If
    FillStyle = vbFSSolid
    DrawStyle = vbTransparent
    dclr = (COLOR_INNER - COLOR_OUTER) / r
    clr = COLOR_OUTER
    For i = r To 1 Step -1
        FillColor = RGB(0, 0, clr)
        ForeColor = RGB(0, 0, clr)
        clr = clr + dclr
        Circle (cx, cy), i, , , , cy / cx
    Next i
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated