Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.060 Beiträge
 
Delphi 10.4 Sydney
 
#12

AW: Canvas RoundRect aber wie

  Alt 16. Jun 2021, 09:01
Ich versuche es nochmal mit ein bisschen guten Willen und Beispielquelltext.
Bitte einfach ein neues VCL-Projekt erstellen, einen Paint-Eventhandler zusammenklicken und folgenden Quelltext reinkopieren:

Delphi-Quellcode:
procedure TForm1.FormPaint(Sender: TObject);
var
    R: TRect;
    X, Y: Integer;
begin
    Self.Canvas.Pen.Width := 3;

    Self.Canvas.Brush.Color := clWebYellowGreen;
    Self.Canvas.Pen.Color := clWebGreen;

    R := Self.ClientRect;

    R.Offset(0, R.Height div 2);

    X := Round(R.Width * 0.1);
    Y := Round(R.Height * 0.1);
    R.Inflate(-X, -Y);

    Self.Canvas.Rectangle(R.Left, R.Top, R.Right, R.Bottom);

    Self.Canvas.Brush.Color := clWebLavender;
    Self.Canvas.Pen.Color := clWebChocolate;

    X := Round(R.Width * 0.1);
    Y := Round(R.Height * 0.1);
    R.Inflate(-X, -Y);

    Self.Canvas.RoundRect(R.Left, R.Top, R.Right, R.Bottom, 30, 30);

    Self.Canvas.Brush.Color := clWebLightYellow;
    Self.Canvas.Pen.Color := clWebFirebrick;

    X := Round(R.Width * 0.1);
    Y := Round(R.Height * 0.1);
    R.Inflate(-X, -Y);

    Self.Canvas.RoundRect(R.Left, R.Top, R.Right, R.Bottom, 10, 10);

    Self.Canvas.Brush.Color := clWebLightSlateGray;
    Self.Canvas.Pen.Color := clWebOrchid;

    X := Round(R.Width * 0.1);
    Y := Round(R.Height * 0.1);
    R.Inflate(-X, -Y);

    Self.Canvas.RoundRect(R.Left, R.Top, R.Right, R.Bottom, X, Y);
end;
Miniaturansicht angehängter Grafiken
roundrect.png  

Geändert von TiGü (16. Jun 2021 um 09:03 Uhr) Grund: Bild hinzugefügt
  Mit Zitat antworten Zitat