Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get kivy lines to be drawn consistently

I'm trying to draw a simple "X" in the middle of a button. I've put in the following drawing code:

    width, height = self.size
    x, y = self.pos
    x1, x2 = x + int(width*0.3), x + int(width*0.7)
    y1, y2 = y + int(height*0.3), y + int(height*0.7)
    with self.canvas:
        Line(points=[x1, y1, x2, y2], width=1, cap='none')
        Line(points=[x2, y1, x1, y2], width=1, cap='none')
    self.canvas.ask_update()

The two diagonal lines, even though they're using the exact same integer coordinates, are not drawn the same. The upper-left to lower-right is drawn aliased, and the other is not. How can I make them consistent?

enter image description here

I should mention that I'm testing with the Windows version of kivy and I haven't tried it on any other platform yet.

like image 670
Mark Ransom Avatar asked Nov 03 '22 07:11

Mark Ransom


1 Answers

Add 0.5 or 0.375 to your x/y coordinates.

like image 180
genpfault Avatar answered Nov 11 '22 05:11

genpfault