微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Silverlight 引路蜂二维图形库示例:多义线和多边形

Graphics2D提供了Fillpolygon ,drawpolyline来填充和绘制多边形和多义线

private void polys()
{
 AffineTransform mat1;
 /** Colors */
 Color redColor = new Color(0x96ff0000,true);
 Color greenColor = new Color(0xff00ff00,false);
 Color blueColor = new Color(0x750000ff,true);
 
 polyline polyline;
 polygon polygon;
 polygon polygon1;
 
 string pointsdata1 = "59,45,95,63,108,105,82,139,39,140,11,107,19,65";
 mat1 = new AffineTransform();
 mat1.Translate(130,140);
 mat1.Rotate(-30 * Math.PI / 180.0);
 polyline = new polyline();
 polygon = new polygon();
 polygon1 = new polygon();
 Point[] points = Point.FromString(pointsdata1);
 for (int i = 0; i < points.Length; i++)
 {
  polyline.AddPoint(points[i].X,points[i].Y);
  polygon.AddPoint(points[i].X,points[i].Y);
  polygon1.AddPoint(points[i].X,points[i].Y);
 }
 //Clear the canvas with white color.
 graphics2D.Reset();
 graphics2D.Clear(Color.White);
 
 graphics2D.AffineTransform = new AffineTransform();
 SolidBrush brush = new SolidBrush(greenColor);
 graphics2D.Fillpolygon(brush,polygon);
 graphics2D.AffineTransform = mat1;
 brush = new SolidBrush(blueColor);
 Pen pen = new Pen(redColor,5);
 graphics2D.SetPenAndBrush(pen,brush);
 graphics2D.Fillpolygon(null,polygon1);
 graphics2D.Drawpolyline(null,polyline);
}


版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐