代码拉取完成,页面将自动刷新
unit HS.FMX.Objects;
interface
uses
System.Classes,
FMX.Objects, FMX.Graphics, FMX.TextLayout;
type
THSBrushText = class(TText)
private
FBrush: TBrush;
procedure SetBrush(const Value: TBrush);
procedure BrushChanged(Sender: TObject);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Brush: TBrush read FBrush write SetBrush;
end;
implementation
uses
System.Math.Vectors;
{ TGradientText }
procedure THSBrushText.BrushChanged(Sender: TObject);
begin
if FUpdating = 0 then
Repaint;
end;
constructor THSBrushText.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FBrush := TBrush.Create(TBrushKind.Gradient, $FF000000);
FBrush.OnChanged := BrushChanged;
end;
destructor THSBrushText.Destroy;
begin
FBrush.Free;
inherited;
end;
procedure THSBrushText.Paint;
var
lTextPath: TPathData;
begin
Canvas.Fill.Assign(FBrush);
Canvas.Stroke.Kind := TBrushKind.None;
lTextPath := TPathData.Create;
try
Canvas.TextToPath(lTextPath, Self.BoundsRect, Self.Text, Layout.WordWrap, Layout.HorizontalAlign, Layout.VerticalAlign);
Canvas.FillPath(lTextPath, 1);
Canvas.DrawPath(lTextPath, 1);
finally
lTextPath.Free;
end;
end;
procedure THSBrushText.SetBrush(const Value: TBrush);
begin
FBrush.Assign(Value);
end;
end.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。