其他分享
首页 > 其他分享> > Direct2D (15) : 剪辑

Direct2D (15) : 剪辑

作者:互联网

Direct2D (15) : 剪辑


绘制在 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;


效果图:

o_201104031.png

posted on 2011-04-03 10:19  万一  阅读(1828)  评论(0)  编辑  收藏

标签:剪辑,15,RClip,Color,cvs,RenderTarget,Direct2D
来源: https://blog.51cto.com/u_14617575/2745410