tags:

views:

86

answers:

3

Possible Duplicate:
Draw Thick Line with Border

I am trying to draw a thick line using c++, and add a border to this line from all side. I am using moveto, lineto functions, but not sure how to track the line width to draw borders.

A: 

have you tried to draw it twice: first with the thickness increased by 2*border width and the border color and then with the line color and thickness?

Philipp
I'll try this, but some cases i need to give effect to border like antialias effect, in this case i need to have the thick line already drawn and put the border as final step to be merged with the right color.
ken
A: 

What way does your line go? If it is horizontal / vertical, then a "thick line" is a rectangle, and Rectangle() draws a rectangle "outlined by using the current pen and filled by using the current brush", so you can do line with a border in one go. However if you want a generic line, at arbitrary angles, let me be the first to point out that this won't be any use, in which case go for Philipp's suggestion.

AAT
Actually i need this for generic line.
ken
A: 

Did you give this a try? It is part of .Net framework

http://msdn.microsoft.com/en-us/library/ms533854(v=VS.85).aspx

Pen blackPen(Color(255, 0, 0, 0), 1);
Pen greenPen(Color(255, 0, 255, 0), 10);
stat = greenPen.SetAlignment(PenAlignmentCenter);

// Draw the line with the wide green pen.
stat = graphics.DrawLine(&greenPen, 10, 100, 100, 50);

// Draw the same line with the thin black pen.
stat = graphics.DrawLine(&blackPen, 10, 100, 100, 50);

If you use LineTo, then it uses the current Pen, which can be created by CreatePen

http://msdn.microsoft.com/en-us/library/dd183509(VS.85).aspx

an example:

http://www.functionx.com/win32/Lesson15.htm

動靜能量
i'll try this, but as i commented below to Philipp's suggestion."some cases i need to give effect to border like antialias effect, in this case i need to have the thick line already drawn and put the border as final step to be merged with the right color"
ken