1
0
lazarus-tutorials/drawing demo/drawing.pas

57 lines
992 B
ObjectPascal

unit drawing;
{$mode objfpc}{$H+}
interface
uses
Classes, Controls, Graphics;
type TDrawing = class(TGraphicControl)
private
FExtent: integer;
public
constructor Create(theOwner: TComponent; anExtent: integer); overload;
property Extent: integer read FExtent write FExtent;
end;
TSquare = class(TDrawing)
public
procedure Paint; override;
end;
TCircle = class(TDrawing)
public
procedure Paint; override;
end;
implementation
constructor TDrawing.Create(theOwner: TComponent; anExtent: integer);
begin
inherited Create(theOwner);
FExtent := anExtent;
Width := FExtent;
Height := FExtent;
end;
{TCircle}
procedure TCircle.Paint;
begin
Canvas.Brush.Color := clBtnFace;
Canvas.FillRect(0, 0, FExtent, FExtent);
Canvas.Brush.Color := clYellow;
Canvas.Ellipse(0, 0, FExtent, FExtent);
end;
{TSquare}
procedure TSquare.Paint;
begin
Canvas.Brush.Color := clSilver;
Canvas.FillRect(0, 0, FExtent, FExtent);
Canvas.Rectangle(0, 0, FExtent, FExtent);
end;
end.