Drawing simmetrical arrow
-
Hi everybody!
I have some problem with simmetrical drawing an arrow. I need draw that:
For drawing I use QPolygon because my arrow must be brushed inside. But I get the next result:
(Sorry for the small picture, you can open it in the new Tab and scalling)
So, how can I get simmetrical figure? My code below:
QPolygon poly; poly << QPoint(67, 237) << QPoint(68, 235) << QPoint(69, 233) << QPoint(70, 231) << QPoint(71, 233) << QPoint(72, 235) << QPoint(73, 237); painter.drawPolygon(poly);
Drawing with individual lines can be a bit inconvenient, because I have a lot of such arrows and generally use an array of points (in the code, I have just taken specific points to practice the method with one arrow).
Thank you in advance for your help!
-
@jsulm said in Drawing simmetrical arrow:
Looks like the arrow is cut on the right side - is this the issue you mean?
Yes, you're right. But that's okay, I moved the right side 1 pixel to the left, and that clipping disappeared. But you can see the asymmetry of the pixels on the left and right sides
@jsulm said in Drawing simmetrical arrow:
Maybe the widget where you're drawing the arrow is too small?
I have widget with size 643x620, I don't think this is a small area. But the thing is that in my question, the first image is reproduced in Photoshop as an example, but it is already programmatically rendered without symmetry. Is there any way to make the lines draw symmetrically?
-
@Vlad02 said in Drawing simmetrical arrow:
Is there any way to make the lines draw symmetrically?
I think you have to change your points. Keep in mind that a
QPen
has also a width. If your arrow line has a width represented by an even number, there is no center to put the "head" of the arrow. It will always look asymmetrical. So better use odd numbers if your head is also like 3, 5, or 7 units wide. -
I have pen width equal 1. The problem there is that the pixels on the left side are drawn one way, and on the right another, and the pixels on the right side suit me. Could it be related to the direction of the drawing? Because the left side is drawn from bottom to top, and the right side is drawn from top to bottom
-