Kivy drawing canvas memory usage

16 views
Skip to first unread message

Evgeniy Nekrasov

unread,
Dec 19, 2019, 5:01:06 AM12/19/19
to Kivy users support
Hello, friends! I have simple app with kivy, and drawing on canvas Ellipse element! But found something strange, when the size of Ellipse object increase to 30.000 on my phone the program crashes, I think because of memory out! And my question, how for example I can draw each pixel of my size screen (1024x768), or maybe another bigest resolution or there is no way to do that in kivy?

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import (Color, Ellipse)
from kivy.clock import Clock
import random

class Canvas_w(Widget):
    def __init__(self, **kwargs):
        super(Canvas_w, self).__init__(**kwargs)
        i=0
        Clock.schedule_interval(self.draw, 0.00001)
    def draw(self,s):
        for i in range(0,100):
            with self.canvas:
                Color(1,1,1)
                a = Ellipse(pos = (random.randint(0,400),random.randint(0,400)), size = (1,1))
                a = None --------------> here try to delete object ,but it doesn't work
                self.canvas.remove(a)------------------------------> not help
              
class MyApp(App): 
    def build(self):
        self.painter = Canvas_w()
        return self.painter
if __name__=="__main__":
    MyApp().run()

Alexander Taylor

unread,
Dec 19, 2019, 6:58:23 AM12/19/19
to Kivy users support
Reply all
Reply to author
Forward
0 new messages