AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

FMX.Graphics.TCanvas.FillText drehen

Ein Thema von himitsu · begonnen am 3. Sep 2025 · letzter Beitrag vom 5. Sep 2025
 
philipp.hofmann

Registriert seit: 21. Mär 2012
Ort: Hannover
950 Beiträge
 
Delphi 10.4 Sydney
 
#8

AW: FMX.Graphics.TCanvas.FillText drehen

  Alt 3. Sep 2025, 17:54
Ich nutze bei mir die folgende Funktion, dürfte dem oben kommunizierten entsprechen:

Delphi-Quellcode:
class procedure TDrawUtils.drawRotatedText(Canvas: TCanvas; x,y,xw,angle: Single; color: TAlphaColor; HTextAlign, VTextAlign: TTextAlign; const S: String);
var
  W: Single;
  H: Single;
  R: TRectF;
  SaveMatrix: TMatrix;
  Matrix: TMatrix;
begin
  W := Canvas.TextWidth(S);
  H := Canvas.TextHeight(S);
  r:=RectF(x,y,x+w,y+h);
  if (angle=270) then
    x:=x+((xw-(h*0.25))*0.5);
  case HTextAlign of
    TTextAlign.Center: R.Left := -W / 2;
    TTextAlign.Leading: R.Left := 0;
    TTextAlign.Trailing: R.Left := -W;
  end;
  R.Width := W;
  case VTextAlign of
    TTextAlign.Center: R.Top := -H / 2;
    TTextAlign.Leading: R.Top := 0;
    TTextAlign.Trailing: R.Top := -H;
  end;
  R.Height := H;
  SaveMatrix:=Canvas.matrix;
  matrix:=TMatrix.CreateRotation(DegToRad(angle));
  matrix.m31:=x;
  matrix.m32:=y;
  Canvas.MultiplyMatrix(matrix);
  Canvas.Stroke.Color := color;
  Canvas.Fill.Color := color;
  Canvas.Stroke.Kind := TBrushKind.Solid;
  Canvas.Stroke.Thickness := 1;
  Canvas.FillText(R, S, False, 1, [], HTextAlign, VTextAlign);
  Canvas.SetMatrix(SaveMatrix);
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:47 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz