uses Direct2D, TypInfo;
procedure TForm1.FormCreate(Sender: TObject);
var
f: TTextFormats;
begin
for f := Low(TTextFormats) to High(TTextFormats) do
CheckListBox1.Items.Add(GetEnumName(TypeInfo(TTextFormats), Ord(f)));
CheckListBox1.Align := alRight;
Edit1.Align := alBottom;
Edit1.OnChange := CheckListBox1.OnClick;
end;
procedure TForm1.CheckListBox1Click(Sender: TObject);
begin
Repaint;
end;
procedure TForm1.FormPaint(Sender: TObject);
var
cvs: TDirect2DCanvas;
fmt: TTextFormat;
i: Integer;
R: TRect;
txt: string;
begin
for i := 0 to CheckListBox1.Count - 1 do
if CheckListBox1.Checked[i] then Include(fmt, TTextFormats(i));
txt := Edit1.Text;
cvs := TDirect2DCanvas.Create(Canvas, ClientRect);
cvs.BeginDraw;
cvs.TextOut(20, 20, txt); //普通文本
cvs.Pen.Color := clGray;
cvs.Brush.Color := clYellow;
cvs.Font.Size := 24;
cvs.Font.Color := clRed;
cvs.Font.Style := [fsBold, fsItalic];
R := Rect(20, 40, 256, 200);
cvs.Rectangle(R);
cvs.TextRect(R, txt, fmt); //矩形范围中的文本
cvs.EndDraw;
cvs.Free;
end;
效果图:
最后
以上就是眯眯眼背包最近收集整理的关于Direct2D (10) : 文本输出初步的全部内容,更多相关Direct2D内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复