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); }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值