Silverlight 引路蜂二维图形库示例:坐标变换
来源:互联网 发布:短线必杀神器 源码 编辑:程序博客网 时间:2024/03/28 21:29
类AffineTransform用于二维平面上坐标变换。可以对坐标进行平移,缩放,旋转等变换。下面例子显示了坐标变换的用法。
private void Transform(){ Path path; /* The first matrix */ AffineTransform matrix1 = new AffineTransform(); /* The second matrix */ AffineTransform matrix2 = new AffineTransform(); /* The third matrix */ AffineTransform matrix3 = new AffineTransform(); /** Colors */ Color blackColor = new Color(0xff000000, false); Color redColor = new Color(0xffff0000, false); Color greenColor = new Color(0xff00ff00, false); Color blueColor = new Color(0xff0000ff, false); Color fillColor = new Color(0x4f0000ff, true); /* Define the path */ path = new Path(); path.MoveTo(50, 0); path.LineTo(0, 0); path.LineTo(0, 50); /* Define the matrix1 as "translate(50,50)" */ matrix1.Translate(50, 50); /* Define the matrix2 as "translate(50,50) + rotate(-45)" */ matrix2 = new AffineTransform(matrix1); AffineTransform m = new AffineTransform(); m.Rotate(-45 * Math.PI / 180.0, 0, 0); /* Concatenates the m to the matrix2. * [matrix2] = [matrix2] * [m]; */ matrix2.Concatenate(m); /* Define the matrix3 as * "translate(50,50) + rotate(-45) + translate(-20,80)" */ /* Copy the matrix2 to the matrix3 */ matrix3 = new AffineTransform(matrix2); m = new AffineTransform(); m.Translate(-20, 80); /* Concatenates the m to the matrix3. * [matrix3] = [matrix3] * [m] */ matrix3.Concatenate(m); //Clear the canvas with white color. graphics2D.Clear(Color.White); graphics2D.AffineTransform = (matrix1); SolidBrush brush = new SolidBrush(fillColor); Pen pen = new Pen(redColor, 4); graphics2D.SetPenAndBrush(pen, brush); graphics2D.Draw(null, path); graphics2D.AffineTransform = (matrix2); pen = new Pen(greenColor, 4); graphics2D.SetPenAndBrush(pen, brush); graphics2D.Draw(null, path); graphics2D.AffineTransform = (matrix3); pen = new Pen(blueColor, 4); graphics2D.SetPenAndBrush(pen, brush); graphics2D.Draw(null, path); }
private void Transform()
{
Path path;
/* The first matrix */
AffineTransform matrix1 = new AffineTransform();
/* The second matrix */
AffineTransform matrix2 = new AffineTransform();
/* The third matrix */
AffineTransform matrix3 = new AffineTransform();
/** Colors */
Color blackColor = new Color(0xff000000, false);
Color redColor = new Color(0xffff0000, false);
Color greenColor = new Color(0xff00ff00, false);
Color blueColor = new Color(0xff0000ff, false);
Color fillColor = new Color(0x4f0000ff, true);
/* Define the path */
path = new Path();
path.MoveTo(50, 0);
path.LineTo(0, 0);
path.LineTo(0, 50);
/* Define the matrix1 as "translate(50,50)" */
matrix1.Translate(50, 50);
/* Define the matrix2 as "translate(50,50) + rotate(-45)" */
matrix2 = new AffineTransform(matrix1);
AffineTransform m = new AffineTransform();
m.Rotate(-45 * Math.PI / 180.0, 0, 0);
/* Concatenates the m to the matrix2.
* [matrix2] = [matrix2] * [m];
*/
matrix2.Concatenate(m);
/* Define the matrix3 as
* "translate(50,50) + rotate(-45) + translate(-20,80)" */
/* Copy the matrix2 to the matrix3 */
matrix3 = new AffineTransform(matrix2);
m = new AffineTransform();
m.Translate(-20, 80);
/* Concatenates the m to the matrix3.
* [matrix3] = [matrix3] * [m]
*/
matrix3.Concatenate(m);
//Clear the canvas with white color.
graphics2D.Clear(Color.White);
graphics2D.AffineTransform = (matrix1);
SolidBrush brush = new SolidBrush(fillColor);
Pen pen = new Pen(redColor, 4);
graphics2D.SetPenAndBrush(pen, brush);
graphics2D.Draw(null, path);
graphics2D.AffineTransform = (matrix2);
pen = new Pen(greenColor, 4);
graphics2D.SetPenAndBrush(pen, brush);
graphics2D.Draw(null, path);
graphics2D.AffineTransform = (matrix3);
pen = new Pen(blueColor, 4);
graphics2D.SetPenAndBrush(pen, brush);
graphics2D.Draw(null, path);
}
- Silverlight 引路蜂二维图形库示例:坐标变换
- Silverlight 引路蜂二维图形库示例:概述
- Silverlight 引路蜂二维图形库示例:包定义
- Silverlight 引路蜂二维图形库示例:基本知识
- Silverlight 引路蜂二维图形库示例:绘制各种几何图形
- Silverlight 引路蜂二维图形库示例:颜色
- Silverlight 引路蜂二维图形库示例:虚线类型
- Silverlight 引路蜂二维图形库示例:不同线宽
- Silverlight 引路蜂二维图形库示例:椭圆
- Silverlight 引路蜂二维图形库示例:路径
- Silverlight 引路蜂二维图形库示例:颜色渐变
- Silverlight 引路蜂二维图形库示例:材质画刷
- Silverlight 引路蜂二维图形库示例:显示位图
- Silverlight 引路蜂二维图形库示例:动画Beziers曲线
- Silverlight 引路蜂二维图形库示例:矢量字体
- Silverlight 引路蜂二维图形库示例:结束语
- Silverlight 引路蜂二维图形库示例:线段末端形状(LineCap)
- Silverlight 引路蜂二维图形库示例:线段连接类型(LineJoin)
- VB解析XML
- GPS定位API
- linux 内核tcp数据发送的实现
- OPENGL函数库介绍
- expected identifier 报错怎么办?
- Silverlight 引路蜂二维图形库示例:坐标变换
- js的event使用
- 使用PowerDesigner 设计SQL Server 数据库
- MII总线基础知识
- MySQL新建用户,授权,删除用户,修改密码
- 线程池 C++实现
- 【转】MySql错误:error :Can't connect to MySQL server (10060)解决办法
- Trafficserver Cluster模式
- TrafficServer一致性hash实现