欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-11-21 16:37:34
本文实例讲述了c#中graphicspath的warp方法用法。分享给大家供大家参考。具体实现方法如下: using system; using system....

本文实例讲述了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#程序设计有所帮助。