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;


效果图:

Direct2D (15) : 剪辑

posted on 2011-04-03 10:19  万一  阅读(1828)  评论(0)  编辑  收藏
上一篇:关于ListView中convertView的缓存个数的探究


下一篇:Direct2D (12) : 画刷之 ID2D1RadialGradientBrush