FMX.Graphics.TCanvas.IntersectClipRect
Delphi
procedure IntersectClipRect(const ARect: TRectF); virtual;
C++
virtual void __fastcall IntersectClipRect(const System::Types::TRectF &ARect);
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
public | FMX.Graphics.pas FMX.Graphics.hpp |
FMX.Graphics | TCanvas |
Description
Defines the drawing area by intersecting the current clipping area of the TCanvas and a rectangle.
The ARect
parameter specifies the rectangle used in the intersection.
If ARect
is empty, IntersectClipRect does nothing. It does not raise any errors.
Note: The clipping rectangle only operates if the canvas state is first saved using SaveState.
Examples
Code structure example:
var
MyCanvas: TCanvas;
Save: TCanvasSaveState;
MyRect : TRectF;
begin
try
Save := MyCanvas.SaveState;
// Create the clipping rectangle
MyRect.Create (20, 20, 100, 100);
MyCanvas.IntersectClipRect (MyRect);
// Do your drawing here
finally
MyCanvas.RestoreState(Save);
end;
end;
Complete demo example:
procedure TForm1.IntersectBtnClick(Sender: TObject);
var
Canvas: TCanvas;
MyRect: TRectF;
Save: TCanvasSaveState;
begin
Canvas := Image1.Bitmap.Canvas;
MyRect := TRectF.Create(TPointF.Create(50, 50), 160, 160);
Canvas.BeginScene;
try
Save := Canvas.SaveState;
try
Canvas.InterSectClipRect(MyRect);
Canvas.Stroke.Color := TAlphaColorRec.Lime;
Canvas.Stroke.Thickness := 3;
Canvas.Stroke.Dash := TStrokeDash.Dash;
Canvas.DrawRect(MyRect, 0, 0, [], 1);
Canvas.Fill.Color := TAlphaColorRec.Red;
Canvas.Fill.Kind := TBrushKind.Solid;
Canvas.FillEllipse(TRectF.Create(TPointF.Create(100, 125), 275, 150), 100);
finally
Canvas.RestoreState(Save);
end;
finally
Canvas.EndScene;
end;
end;