当前位置:编程学习 > C#/ASP.NET >>

C#之GraphicsPath中Warp方法使用代码实例

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Drawing.Drawing2D;
  9. namespace advanced_drawing
  10. {
  11.     public partial class Form13 : Form
  12.     {
  13.         public Form13()
  14.         {
  15.             InitializeComponent();
  16.         }
  17.         private void Form13_Paint(object sender, PaintEventArgs e)
  18.         {
  19.             // Create a path and add a rectangle.
  20.             GraphicsPath myPath = new GraphicsPath();
  21.             RectangleF srcRect = new RectangleF(0, 0, 100, 200);
  22.             myPath.AddRectangle(srcRect);
  23.             // Draw the source path (rectangle)to the screen.
  24.             e.Graphics.DrawPath(Pens.Black, myPath);
  25.             // Create a destination for the warped rectangle.
  26.             PointF point1 = new PointF(200, 200);
  27.             PointF point2 = new PointF(400, 250);
  28.             PointF point3 = new PointF(220, 400);
  29.             PointF[] destPoints = { point1, point2, point3 };
  30.             // Create a translation matrix.
  31.             Matrix translateMatrix = new Matrix();
  32.             translateMatrix.Translate(100, 0);
  33.             // Warp the source path (rectangle).
  34.             myPath.Warp(destPoints, srcRect, translateMatrix,
  35.                 WarpMode.Perspective, 0.5f);
  36.             // Draw the warped path (rectangle) to the screen.
  37.             e.Graphics.DrawPath(new Pen(Color.Red), myPath);
  38.         }
  39.     }
  40. }
补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,