I'm using WPF to draw the polyline with certain width, the sample code is as follows:
DrawingContext.DrawGeometry(Brushes.Yellow, new Pen(Brush, polylineWidth), streamGeometry);
where the streamGeometry is the geometry of the polyline. The result Looks like:
However, I'd like to add borders around the polyline, which looks like:
I know I can draw two polylines with different width (one for the black background, and the other for the color I want to render) I just wonder is there any API or some elegant way to achieve this?
There is only one additional step needed to accomplish that. Create a new shape out of your polyline (the thickness of the polyline included). Use:
var pathGeometry = streamGeometry.GetWidenedPathGeometry (new Pen(Brushes.Black, polylineWidth));
Then call
DrawingContext.DrawGeometry(Brushes.Yellow, new Pen(strokeBrush, strokeThickness), pathGeometry);
and you are done.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.