Reputation: 4776
I have come across a rather funny issue. I have a form with its Fill
set to Gradient
.
On Windows, IOS and OSX, the gradient is drawn as it should be. But on Android, the colors are wrong. Any ideas?
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 480
ClientWidth = 640
Fill.Kind = Gradient
Fill.Gradient.Points = <
item
Color = xFFFFC600
Offset = 0.000000000000000000
end
item
Color = xFFFFF100
Offset = 1.000000000000000000
end>
Fill.Gradient.StartPosition.Y = 0.500000000000000000
Fill.Gradient.StopPosition.X = 1.000000000000000000
Fill.Gradient.StopPosition.Y = 0.500000000000000000
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
DesignerMasterStyle = 0
object Button1: TButton
Position.X = 8.000000000000000000
Position.Y = 8.000000000000000000
TabOrder = 0
Text = 'Button1'
end
end
Windows:
OSX:
IOS:
Android:
Upvotes: 1
Views: 1431
Reputation:
You are using Delphi, right? Because, I have never seen that syntax used in a Pascal based language, nor was I able to get your code running under Delphi 10 Seattle. Was it created by a code-generator?
I have, however, written up the gradient you were trying to get using Delphi 10 Seattle and Firemonkey. It works and looks the same on every device, even on Android:
procedure TForm1.FormPaint(Sender: TObject; Canvas: TCanvas;
const ARect: TRectF);
var
locGradient: TGradient;
begin
with Canvas do begin
BeginScene;
// Create and initialize the gradient object
locGradient := TGradient.Create;
with locGradient do begin
Color := $FFFFC600;
Color1 := $FFFFF100;
StartPosition .Y := 0.5;
StopPosition .X := 1;
StopPosition .Y := 0.5;
end;
// Assign the created gradient object to the fill property of the canvas
with Fill do begin
Kind := TBrushKind.Gradient;
Gradient := locGradient;
end;
// Create a rectangle which represents the gradient
FillRect( ARect, 0, 0, AllCorners, 1.0 );
EndScene;
end;
FreeAndNIL( locGradient );
end;
This doesn't necessarily answer your question as to why your colour values are messed up on Android only using your code, but then again, your code doesn't seem to follow the common Delphi syntax convention.
Upvotes: 1