Quick Search for:  in language:    
VOTE,Updated,Even,Faster,class,will,fill,Form
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,290,928. lines
 Jobs: 179. postings

 How to support the site

 
Sponsored by:

 
You are in:
 

Does your code think in ink?
Login





Latest Code Ticker for Visual Basic.
Check Placement of Form on Screen
By CubeSolver on 11/20


RT Full Duplex
By Brian Black on 11/20


C++ Template Hack
By OpcodeVoid on 11/20


Click here to see a screenshot of this code!DeskTop Generator
By Ziad Said on 11/20

(Screen Shot)

SQLMan
By Darwin H. de Leon on 11/20


Klik! CompareLib...Co mpare and synchronize schema differences in your Access databases...
By Özden Irmak on 11/20


listview000sher if
By Sherif Omran on 11/20


Using ComboBox instead of TextBox
By SMA Soft on 11/20


Click here to see a screenshot of this code!ColorFade
By SMA Soft on 11/19

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

_SUPER FAST! Gradient Fills (Any Angle) (Updated)

Print
Email
 
winzip icon
Submitted on: 2/19/2000
By: Rocky Clark (Kath-Rock Software) 
Level: Intermediate
User Rating: By 62 Users
Compatibility:VB 5.0, VB 6.0

Users have accessed this code 25150 times.
 
 
     (Updated - Even Faster Now) This class will fill any Form or PictureBox with a Gradient fill starting from Color1 and blending to Color2. Sure, I know you've seen that plenty of times, but this code allows you to select any angle 0º to 359.99999º and it does a perfect blend at all angles. Use any colors, even system colors. Create multiple special effects by setting PictureBoxes next to each other and filling them in different directions. Includes full source code and sample program. PLEASE VOTE FOR ME!

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.

Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:
1)Re-scan downloaded files using your personal virus checker before using it.
2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
3)Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 12 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
2/19/2000 4:58:50 PM:Rocky Clark
PLEASE LEAVE A COMMENT AND A VOTE. This 
will keep the code coming.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/19/2000 7:35:58 PM:Karl
This IS the best code I've seen in a 
long time. Thanks for posting it. It is 
very fast and the colors are perfect. 
NICE WORK!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/20/2000 6:18:16 AM:Gilb
I have to say it, this code is 
fantastic! I can see where you could 
make a few optimisations (I mean, the 
code you use to separate the colour 
values from the RGB long works, however 
it could be a LOT smaller).
Well 
anyway, great stuff and keep it coming!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/21/2000 5:04:16 AM:mohammed
it,s what i want
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/24/2000 2:42:12 AM:Gerhard
it's one of the best codes i've ever 
seen.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/26/2000 6:02:47 AM:Rocky Clark
2/26/2000 - Optimized the code for even 
greater speed. Can now fill a 1280 x 
1024 screen in less than 50 
milliseconds (1/20th of a 
second).
PLEASE VOTE!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/27/2000 1:11:25 PM:KM
This is exceptionally nice code. Well 
commented, nicely formatted and easy to 
follow. I had started my own code to do 
the same thing, but I've replaced it 
with yours. I give this code an 
excellent rating.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/28/2000 5:25:18 AM:John P
Great code!! I'm gonna go look at your 
other stuff.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/7/2000 6:49:13 AM:Randy Mcdowell
This will work perfect for my latest 
installation program. The beta testers 
said the plain blue wash gradient was 
boring, so this outta blow them away!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/24/2000 7:58:56 AM:Adam W
Looks great!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/24/2000 8:00:05 AM:Adam W.
Just as a suggestion, I have read that 
the TimeGetTime API is more accurate 
than GetTickCount for precise timing 
operations.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/8/2000 2:46:24 PM:Picklezz
This is one of the best code for 
gradient things I ever seen
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/16/2000 12:34:37 PM:Bard
Very fine code. Is there a way to 
specify a certain rectangle of the 
object to draw the gradient in?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/16/2000 7:08:46 PM:Rocky Clark (Kath-Rock Software)
Bard,
Yes, you can fill a hidden 
PictureBox and then use the 
PaintPicture method to transfer it into 
any other PictureBox at any 
coordinates.
Rocky
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/17/2000 10:42:49 AM:Bard
I wanted to use it for something 
progressbar like. So I only needed a 
new lower right point. I simply added 
an optional parameter in the draw 
method specifying the percents of the 
box to fill which standard value is 
100. A new right end is calculated 
after the dimensions of the box are 
ftched with 
GetWindowRect.
Rect.right=parameter*Rec
t.right/100
If the parameter is 
omitted or set to 100 it fills to the 
vey right, otherwise not.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/25/2000 5:01:17 PM:sindizzy
Finally learned how to use the CLS in 
any project to draw gradients on any 
picturebox or form. My main question is 
this, Most of my VB programs are based 
on many frames. I like the look and i 
have many seperate option buttons that 
belong in different frames. But if I 
paint the main form with a gradient it 
wont show thru the frames. Is there a 
way to make the frames color 
transparent so that the gradient shows 
thru, yet the frame borders are still 
visible. thanx.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/28/2000 11:52:05 PM:John Leabeater
Great stuff! But I implemented this in 
a project for which I need to transfer 
the gradient to another form. I'm 
stuck. How is this accomplished?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/2/2000 2:18:31 PM:Bard
Hello it's me again.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/2/2000 2:20:39 PM:Bard
Hello it's me again.
Do you know a way 
how to implement conic or elliptic 
gradients such like in Corel Draw?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/2/2000 10:38:43 PM:Rocky Clark
Hey Bard,
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/2/2000 10:40:24 PM:Rocky Clark (Kath-Rock Software)
Hey Bard,
I have just the thing 
you're looking for. It's called 
Ellipse3D and I just put it up on this 
sight. I'll also email it to 
you.
Keep on Coding!
Rocky
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/5/2000 11:17:22 PM:Andri
I like your great idea, it' cool
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/6/2000 6:11:32 AM:Rocky Clark (Kath-Rock Software)
I would like to thank everyone who's 
comments are listed above. You are the 
ones who keep the code coming.
Thank 
You!
Rocky
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/9/2000 2:04:32 PM:Tim Talma
VERY VERY Nice code. Your one of the 
few people who actually free up memory 
when doing grapical work (which we all 
know can be a memory hog). Well comment 
and clearly thought out. I plaed with 
this a little and added the ability to 
pick where the gradient went to on the 
edge of the box (I think this is a type 
of conical gradient mentioned above). 
Anyway keep up the great work.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/17/2000 7:24:37 PM:Oscar Hernandez
Very good Job..congratulations.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/10/2000 9:28:40 PM:cozmik x
whoa.. that code rocks, thanks for 
sharing it with us!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/5/2000 11:28:33 PM:A
Very nice!  Beats the snot out of the 
code I was using! ;)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/14/2000 4:17:02 PM:San Franko
this is very very good, i haven't seen 
u get one bad comment yet!!
this is 
fast too, this is brilliant!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/11/2000 9:32:10 AM:Lockedincupboard
Do u mind if I nick this?
Cheers
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/25/2000 6:42:25 AM:Haaaaallpp
haaaaayy...that's good. i have been 
working on grads myself these days 
(circle grads, multiple circle grads, 
boxed grads till now). yo, how bout a 
gradient class that makes grads from 1 
color to another till the middle, then 
back to the first color? like in ppt. 
AT ANY ANGLE? i was able to do this 
only hor + ver but not diagonally or 
any other angle. but lets c, i'm still 
experimenting...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/5/2000 10:26:31 AM:SourceFalcon
The code works very well, but if you 
modify it to use doubles instead of 
singles and remove the unnecessary cdbl 
commands (considering you're already 
working with doubles after the change) 
you'll actually get greater accuracy 
and about a 33% increase in 
speed.
[Speed increase measured on a 
p-3 700 running the demo full screen 
1280x1024]
Average time using 
original class:  75 ms
Average time 
using modified class:  50 ms
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/30/2000 5:14:04 PM:Tom
I wish all free code was written and 
commented as well!  Thanks for the 
extremely useful function.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/2/2001 2:17:05 PM:Immanuel Ulmer
Amazing. Some time ago I thought how to 
mix the colors and adjust the gradient, 
in order to produce a atractive install 
shield and here I found it. Just 
beautifull. Thank you.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/2/2001 2:19:58 PM:Immanuel Ulmer
Just beautifull. it's what I need to 
make nice forms. Thank you verry much.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/11/2001 11:44:35 AM:Kevin
why cant someboydy make a gradient 
filler for older versions
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/1/2001 11:13:44 PM:Kevin
AHHHH
help me
when i try to set 
anything in the class
or try to use a 
function in the class it tells me 
"Object Required"
ps i have vb4
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/8/2001 9:52:10 AM:Coite
Well better late than never. Vote of 
Excellent. This really is most 
excellent. Contest Winner (I should 
think so) and before I voted 110 Votes. 
I just now came across this, and almost 
two years later.. it's still 
fantastic!
Thanks for sharing this.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/24/2001 4:00:41 PM:Mikael Nordfelth
Wonderful!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/11/2001 2:40:53 PM:Jeroen Paul
Ha, you're the first who has my real 
name on a post, what a honour (NOT). 
Great code!!! It's perfect.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/13/2001 3:51:15 PM:Sergey Olekhnovich
Excellent job! Very useful code!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/5/2002 10:32:44 PM:pj
no offense... But I can not get this to 
work right.  THe demo works great and 
looks awesome, but I need it to work on 
a form background rather then a pic.  
Any suggestions?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/6/2002 6:18:19 AM:Rocky Clark (Kath-Rock Software)
pj,
Look at the DrawGradient() 
procedure on the main form in the demo. 
Here's the code.
    With 
mGradient
        .Angle = mfAngle
     .Color1 = mlColor1
.Color2 = mlColor2
        .Draw 
picDraw
    End With
picDraw.Refresh
Now just replace the 
two instances of "picDraw" with the 
name of your form, like this.
With mGradient
        .Angle = 
mfAngle
        .Color1 = mlColor1
     .Color2 = mlColor2
        .Draw 
frmSomeForm
    End With
frmSomeForm.Refresh
Make sure your 
form has AutoRedraw = True.
That's 
all there is to it!
Rocky
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/17/2002 11:19:17 PM:yoni eza
this is cool men
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/1/2002 11:05:42 AM:Keith Hall
Wow! I love this code. I never thought 
it possible to draw gradients so fast. 
Thanks man.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/11/2002 4:13:53 AM:Waseem Shahzad Bhatti
This is a brilliant code.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/13/2002 5:16:08 PM:Nathanael B
Wow, this is great! 5 planets.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/18/2002 1:25:12 PM:[\DReY\]
Hi Rocky.
I'm use your code in my MP3 
Player please look my project 
andevaluate-me. You can view my code 
searching DReY MP3.
Thanks for your 
time. [\DReY\]
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/14/2003 12:37:56 AM:Roger Gilchrist
Very nice. Small problem, fix:
Edit 
vbp file
Class=clsGradient; 
..\..\Develop\Programming 
Libraries\Gradient.cls
TO
Class=clsGra
dient;Gradient.cls
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/8/2003 1:55:10 AM:
This piece of code is great yaar.... 
Awesome n cool.. and makes for great 
backgorund containers of objects!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/27/2003 10:29:02 AM:
Like everyone else has said... 
Ronnie likes!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.