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

 更新时间:2015年06月12日 14:44:57   作者:zhuzhao  
这篇文章主要介绍了C#中GraphicsPath的Warp方法用法,实例分析了Warp方法的相关使用技巧,需要的朋友可以参考下

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

相关文章

  • Entity Framework使用ObjectContext类

    Entity Framework使用ObjectContext类

    这篇文章介绍了Entity Framework使用ObjectContext类的方法,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2022-06-06
  • Unity中协程IEnumerator的使用方法介绍详解

    Unity中协程IEnumerator的使用方法介绍详解

    本文主要介绍了Unity中协程IEnumerator的使用方法介绍详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2022-06-06
  • c#图片缩放图片剪切功能实现(等比缩放)

    c#图片缩放图片剪切功能实现(等比缩放)

    c#图片缩放剪切功能实现,代码中包含了c#图片处理的一些基础知识,与大家分享
    2013-12-12
  • C#中volatile与lock用法

    C#中volatile与lock用法

    这篇文章主要介绍了C#中volatile与lock用法,较为详细的分析了C#中volatile与lock的适用情况及用法实例,具有一定的参考借鉴价值,需要的朋友可以参考下
    2014-10-10
  • C#实现银行家算法

    C#实现银行家算法

    这篇文章主要为大家详细介绍了C#实现银行家算法,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-05-05
  • C#实现斐波那契数列的几种方法整理

    C#实现斐波那契数列的几种方法整理

    这篇文章主要介绍了C#实现斐波那契数列的几种方法整理,主要介绍了递归,循环,公式和矩阵法等,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-09-09
  • C#中OpenCVSharp实现轮廓检测

    C#中OpenCVSharp实现轮廓检测

    这篇文章主要介绍了C#中OpenCVSharp实现轮廓检测,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-11-11
  • C#禁止textbox复制、粘贴、剪切及鼠标右键的方法

    C#禁止textbox复制、粘贴、剪切及鼠标右键的方法

    这篇文章主要介绍了C#禁止textbox复制、粘贴、剪切及鼠标右键的方法,涉及C#针对窗口消息的处理技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-09-09
  • unity实现透明水波纹扭曲

    unity实现透明水波纹扭曲

    这篇文章主要为大家详细介绍了unity实现透明水波纹扭曲,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2020-05-05
  • 基于C#实现端口扫描器(单线程和多线程)

    基于C#实现端口扫描器(单线程和多线程)

    本文主要介绍了基于C#分别通过单线程和多线程实现端口扫描,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-12-12

最新评论