环绕的字WrapText
来源:互联网 发布:国产rpg单机游戏 知乎 编辑:程序博客网 时间:2024/05/17 01:23
FontMenuForm 基类见:http://blog.csdn.net/u013384702/article/details/17884617
Code:
using System;using System.Drawing;using System.Drawing.Drawing2D;using System.Windows.Forms;namespace CsStudy{ class WrapText : FontMenuForm { float fRadius = 100; public new static void Main() { Application.Run(new WrapText()); } public WrapText() { Text = "Wrap Text"; strText = "猪爷爷"; font = new Font("Times New Roman", 48); } protected override void DoPage(Graphics grph, Color clr, int cx, int cy) { GraphicsPath path = new GraphicsPath(); float fFontSize = PointToPageUnits(grph, font); //添加文本到图形路径 path.AddString(strText, font.FontFamily, (int)font.Style, fFontSize, new PointF(0, 0), new StringFormat()); RectangleF rectf = path.GetBounds(); path.Transform(new Matrix(1, 0, 0, -1, -rectf.Left, GetAscent(grph, font))); float fScale = 2 * (float)Math.PI / rectf.Width; path.Transform(new Matrix(fScale, 0, 0, fScale, 0, 0)); //修改路径 PointF[] aptf = path.PathPoints; for (int i = 0; i < aptf.Length; i++) { aptf[i] = new PointF(fRadius * (1 + aptf[i].Y) * (float)Math.Cos(aptf[i].X), fRadius * (1 + aptf[i].Y) * (float)Math.Sin(aptf[i].X)); } path = new GraphicsPath(aptf, path.PathTypes); //填充路径 grph.TranslateTransform(cx / 2, cy / 2); grph.FillPath(new SolidBrush(Color.Red), path); } }}
效果图:
0 0
- 环绕的字WrapText
- struts2的环绕通知
- spring 的环绕通知
- SpringAOP环绕通知的使用
- 环绕打印1开始的自然数---螺旋
- 文字上右下环绕广告的写法
- 环绕曲线周围的螺旋状粒子
- 自定义view实现图文环绕的效果
- WPF圆形环绕的Loading动画
- Winform圆形环绕的Loading动画
- 如何写出拥抱环绕的代码【转】
- 关于文字环绕图片的问题
- word中插入的图片的环绕方式
- 利用Aop的环绕通知进行权限的处理
- 用DIV做不规则形状的环绕文字
- spring的前置通知,后置通知,环绕通知
- CSSDIV:让文本字符环绕在你的图片周围
- CSS用DIV做不规则形状的环绕文字
- vmware linux系统不能全屏的问题
- 初学者 第一个安卓应用详解 eclipse helloworld
- 某个小事引起的思考
- Ubuntu 通过Deb 安装 MySQL 5.5
- 优先队列(Priority Queue)变种和加强
- 环绕的字WrapText
- C 插入排序 希尔排序
- 着实太懒
- bfd
- UML软件工程组织
- 世间冷暖,人情自知
- Python字符编码
- DLL Hell
- Mongodb入门