绘制在 RenderTarget.PushAxisAlignedClip() 与 RenderTarget.PopAxisAlignedClip() 之间的内容将被指定的矩形剪辑。

uses Direct2D, D2D1;

procedure TForm1.FormPaint(Sender: TObject);
var
  cvs: TDirect2DCanvas;
  R,RClip: TRect;
begin
  cvs := TDirect2DCanvas.Create(Canvas, ClientRect);

  R := ClientRect;
  InflateRect(R, -ClientWidth div 6, -ClientHeight div 6);

  {设置剪辑区域}
  RClip := R;
  InflateRect(RClip, -ClientWidth div 6, 0);

  cvs.BeginDraw;
  cvs.Pen.Color := clGreen;
  cvs.Brush.Color := clGreen;

  cvs.Ellipse(R); //第一个椭圆

  cvs.RenderTarget.PushAxisAlignedClip(RClip, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); //参数2是抗锯齿的模式
  cvs.Brush.Color := clWhite;
  cvs.Ellipse(R); //第二个椭圆
  cvs.RenderTarget.PopAxisAlignedClip;

  cvs.EndDraw;
  cvs.Free;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  Repaint;
end;


效果图:

Direct2D (15) : 剪辑

相关文章:

  • 2021-12-26
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2021-12-22
  • 2021-12-24
  • 2021-08-11
猜你喜欢
  • 2021-12-08
  • 2022-01-11
  • 2022-12-23
  • 2021-07-03
  • 2021-05-02
  • 2021-09-30
  • 2021-11-24
相关资源
相似解决方案