当前位置: 移动技术网 > IT编程>开发语言>c# > C#中GraphicsPath的Warp方法用法实例

C#中GraphicsPath的Warp方法用法实例

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#中graphicspath的warp方法用法。分享给大家供大家参考。具体实现方法如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.drawing.drawing2d;
namespace advanced_drawing
{
  public partial class form13 : form
  {
    public form13()
    {
      initializecomponent();
    }
    private void form13_paint(object sender, painteventargs e)
    {
      // create a path and add a rectangle.
      graphicspath mypath = new graphicspath();
      rectanglef srcrect = new rectanglef(0, 0, 100, 200);
      mypath.addrectangle(srcrect);
      // draw the source path (rectangle)to the screen.
      e.graphics.drawpath(pens.black, mypath);
      // create a destination for the warped rectangle.
      pointf point1 = new pointf(200, 200);
      pointf point2 = new pointf(400, 250);
      pointf point3 = new pointf(220, 400);
      pointf[] destpoints = { point1, point2, point3 };
      // create a translation matrix.
      matrix translatematrix = new matrix();
      translatematrix.translate(100, 0);
      // warp the source path (rectangle).
      mypath.warp(destpoints, srcrect, translatematrix,
        warpmode.perspective, 0.5f);
      // draw the warped path (rectangle) to the screen.
      e.graphics.drawpath(new pen(color.red), mypath);
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网