FMX.Graphics.TCanvas.ExcludeClipRect

From RAD Studio API Documentation
Jump to: navigation, search


Delphi

procedure ExcludeClipRect(const ARect: TRectF); virtual;

C++

virtual void __fastcall ExcludeClipRect(const System::Types::TRectF &ARect);

Properties

Type Visibility Source Unit Parent
procedure
function
public
FMX.Graphics.pas
FMX.Graphics.hpp
FMX.Graphics TCanvas

Description

Excludes a rectangle area from the clipping area of TCanvas.

ExcludeClipRect is implemented by TCanvas descendants to exclude a specified rectangle area from the drawing area of the TCanvas.

The ARect parameter specifies the rectangle area to be excluded, in which drawing has no effect.

If ARect is empty, ExcludeClipRect 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.ExcludeClipRect (MyRect);
    
    // Do your drawing here

  finally   
    MyCanvas.RestoreState(Save);
  end;
end;

Complete demo example:

procedure TForm1.ExcludeBtnClick(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.ExcludeClipRect(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.Aqua;
    Canvas.Fill.Kind := TBrushKind.Solid;
    Canvas.FillEllipse(TRectF.Create(TPointF.Create(10, 10), 125, 125), 100);

  finally
    Canvas.RestoreState(Save);
  end;
  finally
    Canvas.EndScene;
  end;
end;

See Also