Search code examples
kivykivy-language

Ellipse Position


Re: Kivy (Python) - Ellipse Click Event

In the linked thread, the vertices drawn are not positioned relative to the center of the ellipse.

This code is similar to my own, albeit a simplified version. I have tried to adjust the position calculations but have been unsuccessful.

Using the existing code, how can I ensure the vertices are positioned relative to the ellipse?

Note: I wasn't sure whether it was best to start a new thread, reference the existing one, or just paste the relevant code in here, so apologies if I have made the wrong choice.


Solution

  • In the linked question, the Ellipse can be centered on the vertex position using this draw method:

       def draw(self):
            self.pos = (self.position[0] - self.size[0]/2.0, self.position[1] - self.size[1]/2.0)
            self.canvas.clear()
            with self.canvas:
                Color(1., 0, 0)
                Ellipse(pos=self.pos, size=self.size)