FMX Multi point gradients


I am trying to apply a multi point gradient to a TRectangle.
If I just set a two point gradient everything works well, but using the same TRectangle and trying to apply 5 points I am only seeing a partial gradient.

If I use the Delphi IDE to set the multi point gradient it works just fine (in the form preview), the problem is how do I do it in code, I couldn’t find any sample code in my searches.

Here’s the code I’m trying:

BlockBG := TRectangle.Create(MainForm);
BlockBG.Parent := MainForm;
BlockBG.Fill.Kind := TBrushKind.Gradient;

While BlockBG.Fill.Gradient.Points.Count < 5 do BlockBG.Fill.Gradient.Points.Add;

BlockBG.Fill.Gradient.Points[0].Color := $FF535b5e;
BlockBG.Fill.Gradient.Points[1].Color := $FFfefefe;
BlockBG.Fill.Gradient.Points[2].Color := $FF4a5154;
BlockBG.Fill.Gradient.Points[3].Color := $FFfdfdfd;
BlockBG.Fill.Gradient.Points[4].Color := $FF535b5e;
BlockBG.Fill.Gradient.Points[0].Offset := 0.0;
BlockBG.Fill.Gradient.Points[1].Offset := 0.25;
BlockBG.Fill.Gradient.Points[2].Offset := 0.5;
BlockBG.Fill.Gradient.Points[3].Offset := 0.75;
BlockBG.Fill.Gradient.Points[4].Offset := 1;


Comments are closed.