1 Star 1 Fork 1

刘志林/HSControls

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
HS.FMX.Objects.pas 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
刘志林 提交于 2019-06-25 16:54 . 添加项目
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.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Delphi
1
https://gitee.com/lzl_17948876/HSControls.git
git@gitee.com:lzl_17948876/HSControls.git
lzl_17948876
HSControls
HSControls
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385