5

Is there a way to draw an Arc with circular gradient in Firemonkey (10.3)? I tried the following code, but this gives me "green-red-green" instead of "green-red".

with PaintBox1.Canvas do
begin
  BeginScene;

  Stroke.Kind := TBrushKind.Gradient;
  Stroke.Thickness := 20;
  Stroke.Cap := TStrokeCap.Round;
  Stroke.Gradient.Style := TGradientStyle.Linear;
  Stroke.Gradient.Color := TAlphaColors.Green;
  Stroke.Gradient.Color1 := TAlphaColors.Red;

  DrawArc(PointF(250,250),PointF(100,100),-250,320,1);

  EndScene;
end;

The result is:

enter image description here

Chris
  • 306
  • 1
  • 4
  • 17
  • What you need is called [SweepGradient](https://developer.android.com/reference/android/graphics/SweepGradient) (at least that is how this kind of gradient is called on Android) Delphi does not support such gradient at the moment. You would need to create custom shader and apply it. – Dalija Prasnikar Oct 20 '19 at 08:35
  • @DalijaPrasnikar is right! You need a sweep gradient. This type of gradient is not implemented by default in Delphi. I advise you to use the [Skia4Delphi](https://github.com/skia4delphi/skia4delphi) library that supports it. – vfbb Jun 13 '22 at 00:48

0 Answers0