Reputation: 73
I want to draw the outline of a thick line, that was drawn with a geometric pen. The line can be a polygon or a curve, but for simplicity I'm using a straight line.
Given two POINT
variables A and B, the following code draws a black 16-pixel wide line with round endcaps between A and B:
LOGBRUSH lb = {BS_SOLID, clBlack, 0};
HPEN Pen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, 16, &lb, 0, NULL);
HPEN OldPen = SelectObject(DC, Pen);
MoveToEx(DC, A.x, A.y, NULL);
LineTo (DC, B.x, B.y);
SelectObject(DC, OldPen);
The idea was to place the above code between BeginPath(DC)
and EndPath(DC)
, and use StrokePath(DC)
to draw the outline of the thick line, using a 1-pixel pen. But, instead of drawing the outline (the green line in the image), it draws a 1-pixel line between A and B (the red line in the image).
Is there any way to fix this?
Upvotes: 1
Views: 246