Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Paint dashed polyline
Re: Paint dashed polyline [message #34660 is a reply to message #34656] |
Sun, 04 December 2011 11:40   |
|
koldo wrote on Sun, 04 December 2011 00:39 | Hello all
I wanted to paint a dashed polyline, but code like this does not work properly.
How could you do it?
void DrawPolyline(Painter& w, const Vector<Point> &p)
{
for (int i = 1; i < p.GetCount(); ++i)
w.Move(p[i-1]).Line(p[i]).Stroke(2, Black()).Dash("5 2");
}
|
Hi Koldo!
I think you should call Dash() before Stroke(). Also you don't have to call it after each segment - it will make nicer dashing at the vertices.
So I would write the code like this:
void DrawPolyline(Painter& w, const Vector<Point> &p)
{
if(!p.GetCount()) return;
w.Move(p[0]);
for (int i = 1; i < p.GetCount(); ++i)
w.Line(p[i]);
w.Dash("5 2").Stroke(2, Black());
}
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Wed May 14 17:22:55 CEST 2025
Total time taken to generate the page: 0.00746 seconds
|