by Option Explicit (9 Submissions)
Category: Graphics
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating:
(4 Votes)

Almost all the code in this module was written by one of the VB gurus on VBC, Carles P.V. His original submission can be found on VBC at txtCodeId=60580. In that submission he has two modules. One is for linear gradients that can be displayed at any angle, and the other is for circular gradients. My meager contributions to his excellence: - The linear and circular gradient generating routines have been merged into one routine that handles both gradient styles. - Linear gradients can be generated in a "middle-out" fashion - that is, from Color1 to Color2 back to Color1. Makes a nice 3D effect.
- The code that actually displays the gradient has been removed from Carles' gradient generating routines and placed in a separate
procedure. The reason for that is simple - speed. If you need to refresh the gradient background of a usercontrol often, why recalculate the background gradient information every time? Calculate it ONCE, cache it, and redraw it as needed with a simple PaintGradient call. A demo showing the module's capabilities is included. Feedback is welcome but if you wish to vote, please vote not for this but for Carles' submission at txtCodeId=60580. Thanks.
API DeclarationsStretchDIBits
Download OmniGradient v1.00 Gradient generation and display module (16 KB)