Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This code works flawlessly. You can use it to fade...
Author:
KrazyGamer
E-mail:
Click to e-mail author
Submitted:
10/29/2001
Version:
VB3
Compatibility:
VB3, VB4, VB5, VB6
Category:
Graphics
Views:
11591
This code works flawlessly. You can use it to fade between two pictures or whatever.
Declarations:
'none
Code:
Function blendColors(Color1 As Long, Color2 As Long, percent) As Long '******************************************** ' Coloring-Blending Routine by KrazyGamer (krazygamer@hotmail.com) ' ' Takes two colors and blends them according to the given opacity ' value. I've searched far and wide for a math algorithm to achieve ' the same but found nothing but complicated and incorrect procedures. ' Well, I've done it using simple arithmetic, ha ha! The variable ' "percent" is an integer between 0 and 100 that determines the ' opacity of the first color. '******************************************** Dim r1, r2, r, g1, g2, g, b1, b2, b, percent2 '******************************************** ' This little section was taken from another procedure written by ' someone else. I don't remember whose it was, so I cannot give ' credit where it's due. r1 = Color1 And &HFF& r2 = Color2 And &HFF& g1 = (Color1 And &HFF00&) / &H100& g2 = (Color2 And &HFF00&) / &H100& b1 = (Color1 And &HFF0000) / &H10000 b2 = (Color2 And &HFF0000) / &H10000 '******************************************** percent2 = 100 - percent r = ((r1 / 100) * percent) + ((r2 / 100) * percent2) g = ((g1 / 100) * percent) + ((g2 / 100) * percent2) b = ((b1 / 100) * percent) + ((b2 / 100) * percent2) blendColors = RGB(r, g, b) End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement