Copyright © Kambiz R. Khojasteh. All rights reserved.
Get future component updates from http://www.delphiarea.com.
DESCRIPTION
TGradient is an extremely fast gradient fill control with a large set of styles. As built-in, TGradient can draw gradient in 24 styles and provides an easily method to define custom styles. In addition, this control can shift and/or rotate the gradient colors, which could be used for creating animated gradients.
PROPERTIES
- BorderColor: TColor
Determines the color of the control's border.
- BorderWidth: TBorderWidth
Specifies the width of the control’s border.
- ColorBegin: TColor
Determines the initial color of the gradient.
- ColorEnd: TColor
Determines the final color of the gradient.
- Reverse: Boolean
If set to true, logically reverses the value of ColorBegin and ColorEnd properties.
- Rotation: TGradientRotation
TGradientRotation = -100..100
Determines the amount of rotation (in percent) of the gradient colors. When value of this property is positive, direction of rotation is from ColorBegin toward ColorEnd, and for negative values vice versa.
- Shape: TShapeType
TShapeType = (stRectangle, stSquare, stRoundRect, stRoundSquare, stEllipse, stCircle)
Determines the shape of the control.
stRectangle |
|
The shape is a rectangle. |
stSquare |
|
The shape is a square. |
stRoundRect |
|
The shape is a rectangle with rounded corners. |
stRoundSquare |
|
The shape is a square with rounded corners. |
stEllipse |
|
The shape is an ellipse. |
stCircle |
|
The shape is a circle. |
- Shift: TGradientShift
TGradientShift = -100..100
Determines the amount of shift (in percent) of the gradient colors. For positive values ColorBegin shifts toward ColorEnd, and for negative values vice versa.
- Style: TGradientStyle
TGradientStyle = (gsCustom, gsRadialC, gsRadialT, gsRadialB, gsRadialL, gsRadialR, gsRadialTL, gsRadialTR, gsRadialBL, gsRadialBR, gsLinearH, gsLinearV, gsReflectedH, gsReflectedV, gsDiagonalLF, gsDiagonalLB, gsDiagonalRF, gsDiagonalRB, gsArrowL, gsArrowR, gsArrowU, gsArrowD, gsDiamond, gsButterfly)
Determines how the control fills the client area.
gsCustom |
|
When style property is set to this value, the control triggers OnCustom event to get the gradient pattern. |
gsRadialC |
|
Radial - Central |
gsRadialT |
|
Radial - Top |
gsRadialB |
|
Radial - Bottom |
gsRadialL |
|
Radial - Left |
gsRadialR |
|
Radial - Right |
gsRadialTL |
|
Radial - Top Left Corner |
gsRadialTR |
|
Radial - Top Right Corner |
gsRadialBL |
|
Radial - Bottom Left Corner |
gsRadialBR |
|
Radial - Bottom Right Corner |
gsLinearH |
|
Linear - Horizontal |
gsLinearV |
|
Linear - Vertical |
gsReflectedH |
|
Reflected - Horizontal |
gsReflectedV |
|
Reflected - Vertical |
gsDiagonalLF |
|
Diagonal - Linear - Forward |
gsDiagonalLB |
|
Diagonal - Linear - Backward |
gsDiagonalRF |
|
Diagonal - Reflected - Forward |
gsDiagonalRB |
|
Diagonal - Reflected - Backward |
gsArrowL |
|
Arrow - Left |
gsArrowR |
|
Arrow - Right |
gsArrowU |
|
Arrow - Up |
gsArrowD |
|
Arrow - Down |
gsDiamond |
|
Diamond |
gsButterfly |
|
Butterfly |
gsRadialRect |
|
Radial - Rectangular |
- UseSysColors: Boolean
Determines where the control looks for the gradient colors.
KEY METHODS
- procedure BeginUpdate
Suspends screen repainting.
- procedure EndUpdate
Re-enables screen repainting.
- procedure InvalidatePattern
Force the control to regenerate the gradient pattern. This method is useful when you are using custom gradient and want to change the pattern to a new one without changing the other properties of the control.
- function CopyPatternTo(Bitmap: TBitmap): Boolean
Copies the gradient pattern in to the specified bitmap. If the pattern is not available, the function returns False.
KEY EVENTS
- OnMouseEnter: TNotifyEvent
Occurs when the mouse pointer moves over the control.
- OnMouseLeave: TNotifyEvent
Occurs when the mouse pointer moves off from over the control.
- OnCustom: TCustomGradientEvent
TCustomGradientEvent = procedure(Sender: TObject; const Colors: TGradientColors; Pattern: TBitmap) of object
TGradientColors = array[0..255] of TRGBTriple
When Style property is set to gsCustom, control generates this event to get the gradient pattern. Colors parameter is an array of array of gradient colors, and pattern is a 24bit-format bitmap. In this event, your code should define the dimensions of the pattern and set color of its pixels (for more information, please refer to the components demo).
HISTORY
- 2.71 (June 28, 2011)
- Fixed bug in saving ColorEnd property.
- Fixed bug in drawing non-rectangular shape gradients in Delphi 2010.
- 2.70 (June 27, 2011)
- Added Shape property.
- 2.62 (November 18, 2008)
- Support for Delphi 2009 added.
- 2.61 (August 11, 2007)
- Added gsRadialRect style (Thanks to Marco Bianchini).
- 2.60 (April 6, 2006)
- Added BorderWidth and BorderColor properties (Thanks to Tkachenko Vadim).
- Added OnMouseEnter and OnMouseLeave events (Thanks to Tkachenko Vadim).
- The code of radial gradient styles were optimized (Thanks to Tkachenko Vadim).
- 2.52.2 (July 27, 2004)
- The following styles exchanged:
- Linear Horizontal / Linear Vertical
- Linear Forward Diagonal / Linear Backward Diagonal
- Reflected Forward Diagonal / Reflected Backward Diagonal
- 2.52.1 (June 18, 2004)
- The compiler error on Delphi 3 fixed.
- 2.52 (June 17, 2004)
- The new property UseSysColors added (Thanks to Peter Schrooders).
- The new method CopyPatternTo added.
- 2.51 (August 15, 2003)
- The code of radial gradient styles were optimized (Thanks to Wolfgang Kiwus).
- 2.50 (February 3, 2001)
- In this version, the drawing speed increased again.
- Some new gradient styles added.
- Now, the control supports custom gradient style, and as the result, the event OnCustom added.
- Shifting and Rotating operations of the gradient colors and the related properties Shift and Rotation added.
- New methods BeginUpdate, EndUpdate, and InvalidatePattern added.
- The control does not support 16bit platform anymore.
- 2.00 (December 29, 2001)
- The drawing speed increased dramatically.
- New gradient fill styles added and the name of older styles changed.
- 1.00 (September 8, 2000)
- Initial release.
LICENSE
TGradient component is freeware. You may copy component's files AS LONG AS YOU COPY ALL OF THEM. If you want to change the source code in order to improve the component's features, performance, etc. please send me the new source code so that I can have a look at it. The changed source code should contain descriptions what you have changed, and of course your name. The only thing you MAY NOT CHANGE is the ORIGINAL COPYRIGHT INFORMATION.
DISCLAIMER
TGradient is provided "AS IS" without any warranty of any kind, either express or implied. The entire risk as to the quality and performance of the software is with you. The author is NOT liable for any DAMAGES resulting from the use and misuse of the component, especially he is NOT liable for DAMAGES that were caused BY ANY VERSION WHICH HAS NOT BEEN PROGRAMMED BY THE AUTHOR HIMSELF.