5

I have a FireMonkey form with the following code on the OnPaint event of the form. I was expecting a ball with a radial gradient but I only get a red ball, no gradient. Question is what am I doing wrong. Running it on XE3. If I change the gradient style to gsLinear, I do get a linear gradient. Is there something else I have to specify to get the radial gradient to show?

 procedure TForm2.FormPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
 var MyRect : TRectF;
 begin
   MyRect.Create (85, 85, 115, 115);

   Canvas.Fill.Gradient.Style := TGradientStyle.gsRadial;
   Canvas.Fill.Gradient.Color := claRed;
   Canvas.Fill.Gradient.Color1 := claBlue;
   Canvas.Fill.Kind := TBrushKind.bkGradient;
   Canvas.FillEllipse (MyRect, 100);
 end;
rhody
  • 2,274
  • 2
  • 22
  • 40

1 Answers1

3

There appears to be a bug in FireMonkey. If you draw the ellipse at 0,0, the radial gradient is visible. When the ellipse is drawn elsewhere the gradient origin isn't moved but stays at the origin (though now invisible). The bug has apparently been reported as of today, when it will be fixed is another matter. The way round it is to either patch the FMX source code (but I don't have the patch) or use the TEllipse component.

rhody
  • 2,274
  • 2
  • 22
  • 40