c#之GDI简单实现代码及其实例
作业:文档形式
3到5页理解
1.理解
2.源代码解释(1到2页)
3.实现效果
项目地址: https://github.com/zhiyishou/polyer
Demo:https://zhiyishou.github.io/Polyer
[图形学]Delaunay三角剖分算法附C++实现
https://blog.csdn.net/qq_31804159/article/details/81709423
算法丨带内外边界的三角剖分算法(Delaunay)
https://blog.csdn.net/npu2017302288/article/details/80460552
三角剖分算法(delaunay)
https://www.cnblogs.com/zhiyishou/p/4430017.html
GDI
https://www.cnblogs.com/stg609/archive/2008/03/16/1108333.html
1.pen类创建画笔对象:
1) 新建一个Windows应用程序,适当加宽窗体宽度。然后切换到代码方式,添加名称空间引用:
using System.Drawing.Drawing2D;
2) 添加Form1_Paint事件代码
3)在Form1_Load中手动添加paint事件:
this.Paint += new PaintEventHandler(Form1_Paint);
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace drawpicture
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics; //创建画板,这里的画板是由Form提供的.
Pen pen = new Pen(Color.Blue, 10.5f);
g.DrawString("蓝色,宽度为10.5", this.Font,
new SolidBrush(Color.Black), , );
g.DrawLine(pen, new Point(, ), new Point(, ));
pen.Width = ;
pen.Color = Color.Red;
g.DrawString("红色,宽度为2", this.Font,
new SolidBrush(Color.Black), , );
g.DrawLine(pen, new Point(, ), new Point(, ));
pen.StartCap = LineCap.Flat;
pen.EndCap = LineCap.ArrowAnchor;
pen.Width = ;
g.DrawString("红色箭头线", this.Font,
new SolidBrush(Color.Black), , );
g.DrawLine(pen, new Point(, ), new Point(, ));
pen.DashStyle = DashStyle.Custom;
pen.DashPattern = new float[] { , };
pen.Width = ;
pen.EndCap = LineCap.NoAnchor;
g.DrawString("自定义虚线", this.Font,
new SolidBrush(Color.Black), , );
g.DrawLine(pen, new Point(, ), new Point(, ));
pen.DashStyle = DashStyle.Dot;
g.DrawString("点划线", this.Font, new SolidBrush(Color.Black), , );
g.DrawLine(pen, new Point(, ), new Point(, ));
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{ } private void Form1_Load(object sender, EventArgs e)
{
this.Paint += new PaintEventHandler(Form1_Paint);
} private void button1_Click(object sender, EventArgs e)
{ }
}
}
整个源码
运行情况:
2.画刷
public void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush myBrush = new SolidBrush(Color.Red);
g.FillEllipse(myBrush, this.ClientRectangle);
}
最新文章
- 安全退出,清空Session或Cookie
- 2016中国大学生程序设计竞赛(长春) Ugly Problem 模拟+大数减法
- Storm集群的安装配置
- linker command failed with exit code 1 (use -v to see invocation)
- html --- ajax --- javascript --- 简单的封装
- 【转】iOS中定时器NSTimer的使用
- jquery中json数据转换为字典
- Java多线程练习
- QuickReport多页打印
- DB2数据类型
- apollo实现c#与android消息推送(三)
- 异常-----freemarker.core.NonStringException
- 【编程笔记】Unity3D语言的类型系统--C#的类型系统
- 【HDU 1576】 A/B
- torch.view()详解及-1参数是什么意思
- Linux 部署 xxl-job 注意问题
- 001-RESTful服务最佳实践-RestFul准则、HTTP动词表示含义、合理的资源命名、响应格式XML和JSON
- day11 闭包函数和装饰器
- Android.PackageManager
- SVN previous operation has not finished