Direct2D (25) : 将画笔线条所占用的区域转换为路径 - ID2D1Geometry.Widen()
作者:互联网
Direct2D (25) : 将画笔线条所占用的区域转换为路径 - ID2D1Geometry.Widen()
uses Direct2D, D2D1; procedure TForm1.FormPaint(Sender: TObject); var cvs: TDirect2DCanvas; iGeometry: ID2D1Geometry; iPathGeometry: ID2D1PathGeometry; iGeometrySink: ID2D1GeometrySink; begin {建立一个几何对象 iGeometry} D2DFactory.CreateEllipseGeometry( D2D1Ellipse(D2D1PointF(ClientWidth/2, ClientHeight/2), ClientWidth/4, ClientHeight/4), ID2D1EllipseGeometry(iGeometry) ); cvs := TDirect2DCanvas.Create(Canvas, ClientRect); cvs.BeginDraw; {绘制 iGeometry} cvs.Pen.Color := clYellow; cvs.Pen.Width := 25; cvs.DrawGeometry(iGeometry); {创建 iPathGeometry,并把 iGeometry 的线条所占用的区域转换成新的路径到 iPathGeometry} D2DFactory.CreatePathGeometry(iPathGeometry); iPathGeometry.Open(iGeometrySink); iGeometry.Widen(25, nil, TD2DMatrix3x2F.Identity, 0, iGeometrySink); //参数4是曲直容差,效果图中包含把它设为 9 的演示 iGeometrySink.Close; {绘制 iPathGeometry} cvs.Pen.Color := clRed; cvs.Pen.Width := 1; cvs.DrawGeometry(iPathGeometry); cvs.EndDraw; cvs.Free; end; procedure TForm1.FormResize(Sender: TObject); begin Repaint; end;
效果图:
posted on 2011-04-07 11:34 万一 阅读(1369) 评论(0) 编辑 收藏
标签:25,Widen,iGeometry,iGeometrySink,cvs,Pen,Direct2D,iPathGeometry 来源: https://blog.51cto.com/u_14617575/2745400