类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,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); /* 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,path); graphics2D.Affinetransform = (matrix3); pen = new Pen(bluecolor,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,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);
/* Concatenates the m to the matrix2.
* [matrix2] = [matrix2] * [m];
*/
matrix2.Concatenate(m);
/* define the matrix3 as
* "translate(50,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,path);
graphics2D.Affinetransform = (matrix3);
pen = new Pen(bluecolor,path);
}
以上是内存溢出为你收集整理的Silverlight 引路蜂二维图形库示例:坐标变换全部内容,希望文章能够帮你解决Silverlight 引路蜂二维图形库示例:坐标变换所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)