Einzelnen Beitrag anzeigen

Dax
(Gast)

n/a Beiträge
 
#3

Re: Layer Management auf OOP Basis

  Alt 28. Jun 2008, 13:39
Das geht aber schöner und OOPiger
Delphi-Quellcode:
TAbstractLayer = class
  private
    fX, fY, fWidth, fHeight: Integer;
  public
    constructor Create(x, y, width, height: Integer);

    property X: Integer read fX write fX;
    property Y: Integer read fY write fY;
    property Width: Integer read fWidth write fWidth;
    property Height: Integer read fHeight write fHeight;

    procedure DrawTo(bitmap: TBitmap); virtual; abstract;
  end;

  TBitmapLayer = class(TAbstractLayer)
  private
    fBitmap: TBitmap;
  public
    constructor Create(bitmap: TBitmap);

    property Bitmap: TBitmap read fBitmap write fBitmap;

    procedure DrawTo(bitmap: TBitmap); override;
  end;

  TTextLayer = class(TAbstractLayer)
  private
    fText: string;
  public
    constructor Create(text: string);

    property Text: string read fText write fText;

    procedure DrawTo(bitmap: TBitmap); override;
  end;
  Mit Zitat antworten Zitat