Direct2D (29) : 简化曲线到直线 - ID2D1Geometry.Simplify()



uses Direct2D, D2D1;



procedure TForm1.FormPaint(Sender: TObject);

var

  cvs: TDirect2DCanvas;

  iEllipseGeometry: ID2D1EllipseGeometry;

  iPathGeometry: ID2D1PathGeometry;

  iGeometrySink: ID2D1GeometrySink;

  ptCenter: TPoint;

begin

  ptCenter := Point(ClientWidth div 2, ClientHeight div 2);

  D2DFactory.CreateEllipseGeometry(D2D1Ellipse(ptCenter, ClientWidth/4, ClientHeight/4), iEllipseGeometry);



  D2DFactory.CreatePathGeometry(iPathGeometry);

  iPathGeometry.Open(iGeometrySink);

  iEllipseGeometry.Simplify(

    D2D1_GEOMETRY_SIMPLIFICATION_OPTION_LINES,

    TD2DMatrix3x2F.Identity,

    28, //效果图分别演示了此值是 0、7、28 时的简化效果

    iGeometrySink

  );

  iGeometrySink.Close;



  cvs := TDirect2DCanvas.Create(Canvas, ClientRect);

  cvs.BeginDraw;

  cvs.RenderTarget.Clear(D2D1ColorF(clWhite));

  cvs.DrawGeometry(iPathGeometry);

  cvs.EndDraw;

  cvs.Free;

end;



procedure TForm1.FormResize(Sender: TObject);

begin

  Repaint;

end;



效果图:

Direct2D (29) : 简化曲线到直线 - ID2D1Geometry.Simplify()

你可能感兴趣的:(imp)