Reputation: 394
iam trying to draw gradient Background over list view using GraphUtil
, i have only problem with gradient position
here is my custom list view draw event
Var
R: TRect;
begin
// Full ListView
SetRect(R, ARect.Left, ARect.Top, ARect.Right - ((ARect.Right-ARect.Left) div 2), ARect.Bottom );
GradientFillCanvas(Sender.Canvas, panelemo.Color, clWhite, R, gdVertical); // GraphUtil
SetRect(R, ARect.Right - ((ARect.Right-ARect.Left) div 2), ARect.Top, ARect.Right, ARect.Bottom );
GradientFillCanvas(Sender.Canvas, panelemo.Color, clWhite, R, gdVertical);
panelmeter.Color := panelemo.Color;
i want to draw gradient from right to left not from top to bottom like this image
Upvotes: 0
Views: 856
Reputation: 21033
It is unclear what you actually want to have because what you say is different from what you show.
Anyhow, gdHorizontal
means that the color is changing from StartColor
to EndColor
horizontally from left to right. In your image as if you would have specified white as start color and turqoise as end color. If you want to change the horizontal direction (to from right to left), you need to swap the colors.
Example of horizontal using code:
GradientFillCanvas(ListView1.Canvas, AColor, clWhite, R, gdHorizontal);
gdVertical
means that the color is changing vertically, from top to bottom. If you want to change the vertical direction (to from bottom to top), you need to swap the colors.
Example of vertical using code:
GradientFillCanvas(ListView1.Canvas, AColor, clWhite, R, gdVertical);
The sliced result I think you refer to, is caused by the fact that you draw the gradient with two calls to GradientFillCanvas()
once for each half of the TRect
.
Upvotes: 2