BarGradient Function

Microchip Graphics Library

Microchip Graphics Library
BarGradient Function
C
WORD BarGradient(
    SHORT left, 
    SHORT top, 
    SHORT right, 
    SHORT bottom, 
    GFX_COLOR color1, 
    GFX_COLOR color2, 
    DWORD length, 
    BYTE direction
);
Overview

This renders a bar onto the screen, but instead of one color, a gradient is drawn depending on the direction (GFX_GRADIENT_TYPE), length, and colors chosen. This function is a blocking call.

Description

Input Parameters
Input Parameters 
Description 
SHORT left 
x position of the left top corner. 
SHORT top 
y position of the left top corner. 
SHORT right 
x position of the right bottom corner. 
SHORT bottom 
y position of the right bottom corner. 
GFX_COLOR color1 
start color for the gradient 
GFX_COLOR color2 
end color for the gradient 
DWORD length 
From 0-100%. How much of a gradient is wanted 
BYTE direction 
Gradient Direction 
Returns

Always returns a 1 since it is a blocking function.

Preconditions

USE_GRADIENT macro must be defined (in GraphicsConfig.h)

Side Effects

none

Example
// draw a full screen gradient background
// with color transitioning from BRIGHTRED to 
// BLACK in the upward direction.  

GFX_GRADIENT_STYLE  gradScheme;

gradScheme.gradientType         = GRAD_UP; 
gradScheme.gradientStartColor   = BRIGHTRED;
gradScheme.gradientEndColor     = BLACK;

 BarGradient(0,                                         //left position 
             0,                                         //top position
             GetMaxX(),                                 //right position
             GetMaxY(),                                 //bottom position
             gradScheme.gradientStartColor,
             gradScheme.gradientEndColor,
             50,                                        // at the halfway point (50%) of the rectangular area 
                                                        // defined by the first 4 parameters (full screen), 
                                                        // the color becomes BLACK and BLACK color is used until 
                                                        // the rectangle defined is filled up 
             gradScheme.gradientType);                  // see GFX_GRADIENT_TYPE
Microchip Graphics Library Version 3.06.02 - October 15, 2012
Copyright © 2012 Microchip Technology, Inc.  All rights reserved