2021-10-06 11:33:12 -04:00
|
|
|
unit drawing;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, Controls, ExtCtrls, Graphics;
|
|
|
|
|
|
|
|
type TDrawing = class(TGraphicControl)
|
|
|
|
private
|
|
|
|
FExtent: integer;
|
|
|
|
public
|
2021-10-06 15:32:03 -04:00
|
|
|
constructor Create(theOwner: TComponent; anExtent: integer); overload;
|
2021-10-06 11:33:12 -04:00
|
|
|
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.
|
|
|
|
|