C#中GraphicsPath的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#程序设计有所帮助。

(0)

相关推荐

  • C#中GraphicsPath的Widen方法用法实例

    本文实例讲述了C#中GraphicsPath的Widen方法用法.分享给大家供大家参考.具体如下: 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; nam

  • 混合语言编程—C#使用原生的Directx和OpenGL绘图的方法

    由于项目需要做一些图形展示,所以就想到了使用Directx和OpenGL来绘图,但项目准备使用C#来开发(大家比较熟悉C#),在网上看了相关的资料,有一些第三方的控件可用,试用了下,一运行就占了几百M的内存,而且也不知道是否稳定,教程也少,还不如直接使用原生的.在网上看的Directx和OpenGL的教程基本上都是C/C++的,找了很久也就找到相关介绍,只能自己研究下. 我以前做过C#和C++混合语言编程相关的东西,在C++实现一些C#不好实现的功能,C#动态调用DLL文件,所以也想到了用C++

  • 深入c# GDI+简单绘图的具体操作步骤(一)

    最近对GDI+这个东西接触的比较多,也做了些简单的实例,比如绘图板,仿QQ截图等. 最早接触这个类,是因为想做仿QQ截图的效果.巧的很,学会了如何做截图后,.NET课堂上老师也正巧要讲关于c#绘图方面的知识,并且我自己又在网上学习金老师的培训班,也是要用到这个类.在学习中有一些体会,所以准备把这些体会记下来,因为内容比较多,可能我会分几次写.废话不多说了,我们先来认识一下这个GDI+,看看它到底长什么样.GDI+:Graphics Device Interface Plus也就是图形设备接口,提

  • C# GDI在控件上绘图的方法

    本文以在chart控件上和窗体上画矩形为例子讲述了C# GDI在控件上绘图的方法.分享给大家供大家参考.具体方法如下: 具体的实现方法就不多解释了,备注很详细,代码也很简单. 主要功能代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Te

  • C#中GraphicsPath的AddString方法用法实例

    本文实例讲述了C#中GraphicsPath的AddString方法用法.分享给大家供大家参考.具体如下: 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;

  • 深入c# GDI+简单绘图的具体操作步骤(二)

    在上一篇里已经向大家介绍了如何使用GDI+绘制简单的图像,这一片继续向大家介绍其它一些绘图知识.1.首先我们来看下上一片中我们使用过的Pen.Pen的属性主要有: Color(颜色),DashCap(短划线终点形状),DashStyle(虚线样式),EndCap(线尾形状), StartCap(线头形状),Width(粗细)等.我们可以用Pen 来画虚线,带箭头的直线等 复制代码 代码如下: Pen  p = new  Pen(Color.Blue, 5);//设置笔的粗细为,颜色为蓝色Grap

  • C#中GraphicsPath的Flatten方法用法实例

    本文实例讲述了C#中GraphicsPath的Flatten方法.分享给大家供大家参考.具体实现方法如下: 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;

  • C#实现动态数据绘图graphic的方法示例

    本文实例讲述了C#实现动态数据绘图graphic的方法.分享给大家供大家参考,具体如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.

  • C#打印绘图的实现方法

    本文实例讲述了C#打印绘图的实现方法.分享给大家供大家参考.具体实现方法如下: 复制代码 代码如下: String drawString = ""; Font drawFont = null; SolidBrush drawBrush = null; float x = 0F; float y = 0F; StringFormat drawFormat = new StringFormat(); string test = ""; public string Tes

  • 深入c# GDI+简单绘图的具体操作步骤(四)

    前几篇我已经向大家介绍了如何使用GDI+来绘图,并做了一个截图的实例,这篇我向大家介绍下如何来做一个类似windows画图的工具.个人认为如果想做一个功能强大的绘图工具,那么单纯掌握GDI还远远不够,我的目前也只能做一个比较简单的绘图工具了.不足之处,欢迎大家讨论!先来看一下最终效果吧: 主要实现功能:画直线,矩形,橡皮,圆形,切换颜色,打开图片,保存图片,清除图片,手动调节画布大小;软件刚启动时,为一张空白画布,我们可以直接在画布上绘画,也可以通过菜单中的"打开",导入一张图片,然后

  • 深入c# GDI+简单绘图的具体操作步骤(三)

    关于这个的例子其实网上已经有这方面的资料了,但是为了文章的完整性,还是觉得有必要讲解.我们先来看一下效果:                                                                                                                    (图(图1)                                                       ( 图2 )接下来看看这是如何做到的.

  • C#实现Windows Form调用R进行绘图与显示的方法

    一.前提准备 安装R软件,需要安装32位的R软件,64位的调用会报错.另外就是讲R添加到电脑环境变量中. 打开R软件,安装包 scatterplot3d,演示需要用到此R包. 二.创建项目GraphGenerateByR,项目结构如下: 注意:这里需要引入RDotNet类库,可以自行下载:http://rdotnet.codeplex.com/ 三.Main窗体代码 using System; using System.Collections.Generic; using System.Comp

随机推荐