C#绘制三角形并填充,使用winform实现qq聊天气泡
首先是需求,需要制作一个聊天气泡, 但是winform中有没有类似Android的.9图,只有自己设计图形拼接气泡。
第一种是绘制空心三角形,第二种是绘制三角形区域,可以指定RGB颜色。
private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen pen = new Pen(Color.Red, );
e.Graphics.DrawLine(pen, , , , );
e.Graphics.DrawLine(pen, , , , );
e.Graphics.DrawLine(pen, , , , ); Color color = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
Brush brushes = new SolidBrush(color);
Point[] point new Point[];
point[] = new Point(,10);
point[] = new Point(10,);
point[] = new Point(10,10);
e.Graphics.FillPolygon(brushes, point);
}
效果:
可以作为气泡中的箭头,另外四个角用椭圆:
绘制圆角矩形的代码:
//窗口圆角
private void Main_Paint(object sender, PaintEventArgs e)
{
List<Point> list = new List<Point>();
int width = this.Width;
int height = this.Height; #region 四个圆角 //左上
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, )); //右上
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , )); //右下
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - )); //左下
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - )); #endregion Point[] points = list.ToArray(); GraphicsPath shape = new GraphicsPath();
shape.AddPolygon(points); this.Region = new System.Drawing.Region(shape); }
C#绘制三角形并填充,使用winform实现qq聊天气泡的更多相关文章
- winform实现QQ聊天气泡200行代码
c# winform实现QQ聊天气泡界面,原理非常简单,通过webKitBrowser(第三方浏览器控件,因为自带的兼容性差)加载html代码实现,聊天界面是一个纯HTML的代码,与QQ的聊天界面可以 ...
- Linux OpenGL 实践篇-3 绘制三角形
本次实践是绘制两个三角形,重点理解顶点数组对象和OpenGL缓存的使用. 顶点数组对象 顶点数组对象负责管理一组顶点属性,顶点属性包括位置.法线.纹理坐标等. OpenGL缓存 OpenGL缓存实质上 ...
- WebGL编程指南案例解析之绘制三角形
//案例3.绘制三角形,将顶点数据存到缓冲区对象(gl.ARRAY_BUFFER)中,然后顶点着色器从里面读数据(3个顶点) //顶点着色器中去掉gl_PointSize = 10.0,绘制三角不能设 ...
- C#中画三角形和填充三角形的简单实现
C#中画三角形和填充三角形的简单实现: private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graph ...
- 纯CCS绘制三角形箭头图案
用CSS绘制三角形箭头.使用纯CSS,你只需要很少的代码就可以创作出各种浏览器都兼容的三角形箭头! CSS代码: /* create an arrow that points up */ div.ar ...
- unity 绘制三角形
哎 该学的还是要学 参考:http://www.narkii.com/club/thread-369573-1.html unity 顶点绘制三角形 脚本绘制; 其实filter和render就是进行 ...
- CSS 魔法系列:纯 CSS 绘制三角形(各种角度)
我们的网页因为 CSS 而呈现千变万化的风格.这一看似简单的样式语言在使用中非常灵活,只要你发挥创意就能实现很多比人想象不到的效果.特别是随着 CSS3 的广泛使用,更多新奇的 CSS 作品涌现出来. ...
- css绘制三角形原理
1.新建一个元素,将它的宽高都设置为0:然后通过设置border属性来实现三角形效果,下面是css绘制三角形的原理: <!DOCTYPE html> <html> <he ...
- 【转载】理解GL_TRIANGLE_STRIP等绘制三角形序列的三种方式
GL_TRIANGLE_STRIP绘制三角形方式很多时候令人疑惑,在这里对其运作机理进行解释. 一般情况下有三种绘制一系列三角形的方式,分别是GL_TRIANGLES.GL_TRIANGLE_STRI ...
随机推荐
- 用SQL语句将远程SQL Server数据库中表数据导入到本地数据库相应的表中
一.方法一 访问不同电脑上的数据库(远程访问,只好联好网就一样),如果经常访问或数据量较大,建议用链接服务器方法. 1.创建链接服务器 exec sp_addlinkedserver ‘srv_lnk ...
- 目标检测 的标注数据 .xml 转为 tfrecord 的格式用于 TensorFlow 训练
将目标检测 的标注数据 .xml 转为 tfrecord 的格式用于 TensorFlow 训练. import xml.etree.ElementTree as ET import numpy as ...
- Matlab 2016b 正式版下载
Matlab 2016b 正式版下载 这两天为完成最优化大作业,zyy又开始鼓捣matlab了.之前我装的是matlab 2013a,发现不支持求解整数规划,遂更新了一下. 下载地址 链接:http ...
- django -- 为model 指定数据库名
一.为model指定数据库名: django自己实现的ORM中.如果要指定一个model的表名是通过Meta类来实现的. from django.db import models # Create y ...
- linux php7.1 安装redis扩展
redis扩展下载网址 http://pecl.php.net/package/redis wget http://101.96.10.64/pecl.php.net/get/redis-3.1.3. ...
- haproxy 作为反向代理被攻击
在工作中.遇到过一个情况就是我们的额网站被某一个网站攻击 页面结果来自于https://i.umeng.com/? (友盟+) 我这里用的是haproxy作为反向代理. 所以这里我就从haproxy这 ...
- LVL类及接口使用介绍(License Verification Library )
原文:http://android.eoe.cn/topic/android_sdk LVL Classes and Interfaces-LVL类和接口 Table 1 lists all of t ...
- Atitit Java OpenCV 捕获视频
Atitit Java OpenCV 捕获视频 ,打开一段视频或默认的摄像头 有两种方法,一种是在定义类的时候,一种是用open()方法. 一. 读取视频序列 OpenCV提供了一个简便易用的框架以 ...
- HTML5学习笔记(二十一):BOM
BOM(Browser Object Model) 是指浏览器对象模型. 由于最初JavaScript就是设计在浏览器中执行的脚本语言,所以BOM是浏览器提供给JavaScript操作自身的接口. w ...
- 菜鸟调错(三)——Jboss与jdk版本不兼容导致WebService调用出错
环境: jdk1.6 Jboss 5.1.0.GA 问题描述: EJB发布webserivce已经成功,并且能够成功访问wsdl文件: 使用axis1自带的sample/client下的类Dynami ...