AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia FMX bunte Polygone zeichnen
Thema durchsuchen
Ansicht
Themen-Optionen

FMX bunte Polygone zeichnen

Ein Thema von bernhard_LA · begonnen am 18. Aug 2020 · letzter Beitrag vom 18. Aug 2020
 
philipp.hofmann

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

AW: FMX bunte Polygone zeichnen

  Alt 18. Aug 2020, 13:52
Ich mache es mit folgendem Code (ist aber eine Vereinfachung, da meine Polygon-Form relativ fix ist):

Delphi-Quellcode:
unit SimplePolygon;

interface

uses
  System.Classes, System.Types, FMX.Objects, System.Math.Vectors;

type
  TSimplePolygon = class(TShape)
  private
    FPoints: TPolygon;
  protected
    procedure Paint; override;
  public
    heightEnd:single;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
  end;

procedure Register;

implementation

uses MyLog;

procedure Register;
begin
  RegisterComponents('Shapes', [TSimplePolygon]);
end;

{ TSimpleTriangle }

constructor TSimplePolygon.Create(AOwner: TComponent);
begin
  inherited;
  SetLength(FPoints, 5);
end;

destructor TSimplePolygon.Destroy;
begin
  Finalize(FPoints);
  inherited;
end;

procedure TSimplePolygon.Paint;
var
  R: TRectF;
begin
  R := GetShapeRect;
  FPoints[0] := PointF(R.Left, R.Bottom);
  FPoints[1] := PointF(R.Left, R.Top);
  FPoints[2] := PointF(R.Right, R.Top-(heightEnd-height));
  FPoints[3] := PointF(R.Right, R.Bottom);
  FPoints[4] := PointF(R.Left, R.Bottom);
  Canvas.Fill.Assign(Self.Fill);
  Canvas.FillPolygon(FPoints, AbsoluteOpacity);
  Canvas.DrawPolygon(FPoints, AbsoluteOpacity);
end;

end.
Delphi-Quellcode:
            polygon:=TSimplePolygon.Create(self);
            polygon.Parent:=myRExercise;
            polygon.beginUpdate;
            polygon.Name:='RECT_'+IntToStr(i)+'_'+IntToStr(j)+'_'+IntToStr(k);
            polygon.OnClick:=btRectClick;
            polygon.Fill.Color:=myExercise.sequenceList[i].legList[k].getLegLevelColor();
            polygon.Stroke.Dash:=TStrokeDash.Solid;
            polygon.Stroke.Color:=TAlphaColors.Black;
            polygon.Stroke.Thickness:=1;
            polygon.Width:=width;
            polygon.Height:=height;
            polygon.HeightEnd:=heightEnd;
            polygon.Position.X:=lastX;
            polygon.Position.Y:=myRExercise.Height-polygon.Height;
            polygon.EndUpdate;
  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 03:53 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