Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the Line End Styles for Canvas.LineTo

Tags:

Is there any way to set the style for the lineends for the TCanvas.LineTo method? It seems to default to rounded ends, which looks very bad for several lines in a row of different colours when Pen.Width is set to a large value (e.g. 9).

It looks like this (rounded ends):

 ********........******
**********........******
**********........******
 ********........******

(where * is e.g. blue and . is yellow)

It is even worse if the two outer lines are drawn after the middle line:

 ********........******
**********......********
**********......********
 ********........******

I'd like it to look like this (streight ends):

 ********........******
 ********........******
 ********........******
 ********........******

Pen does not seem to offer any setting for this and neither does the LineTo method. Is there maybe a windows API function I could call?

like image 791
Thomas Mueller Avatar asked Dec 15 '08 13:12

Thomas Mueller


People also ask

How do I make lines on a canvas?

To draw a line on a canvas, you use the following steps: First, create a new line by calling the beginPath() method. Second, move the drawing cursor to the point (x,y) without drawing a line by calling the moveTo(x, y) . Finally, draw a line from the previous point to the point (x,y) by calling the lineTo(x,y) method.

What is line to in canvas?

The lineTo() method adds a new point and creates a line TO that point FROM the last specified point in the canvas (this method does not draw the line). Tip: Use the stroke() method to actually draw the path on the canvas.


1 Answers

Maybe ExtCreatePen helps. Check the PS_ENDCAP_* and PS_JOIN_* flags.

like image 139
Uli Gerhardt Avatar answered Sep 28 '22 06:09

Uli Gerhardt