📄 subtractrectu.pas
字号:
unit SubtractRectU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormPaint(Sender: TObject);
var
Rect1, Rect2, Subtract: TRect; // holds the rectangles
begin
{set the coordinates of the two test rectangles}
SetRect(Rect1, 10, 10, 110, 110);
SetRect(Rect2, 60, 10, 160, 160);
{subtract rectangle 2 from rectangle 1}
SubtractRect(Subtract, Rect1, Rect2);
with Form1.Canvas do
begin
{initialize canvas objects to draw outlines}
Brush.Style := bsClear;
Pen.Style := psSolid;
{draw the outlines of rectangle 1 and 2}
Rectangle(Rect1.Left, Rect1.Top, Rect1.Right, Rect1.Bottom);
Rectangle(Rect2.Left, Rect2.Top, Rect2.Right, Rect2.Bottom);
{initialize canvas objects to draw the result}
Brush.Style := bsSolid;
Brush.Color := clRed;
{fill the resulting rectangle with red}
FillRect(Subtract);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -