p5 icon indicating copy to clipboard operation
p5 copied to clipboard

particle system run very slowly

Open yonghuming opened this issue 4 years ago • 6 comments

Describe the bug simple particle system run slowly

from p5 import *
from random import randint

class Ball():
    def __init__(self):
        self.x = randint(0, 800)
        self.y = 0
        self.vy = randint(1, 5)
    
    def update(self):
        self.y += self.vy

    def display(self):
        ellipse(self.x, self.y, 100, 100)

    def run(self):
        self.update()
        self.display()
        
balls = []


def setup():
    global balls
    size(800, 600)
    balls = [Ball() for i in range(100)]
    

def draw():
    global balls
    [ball.run() for ball in balls]
    background('red')

run()

To Reproduce just run the code above

Expected behavior as least fluently like https://editor.p5js.org/yonghuming/full/BDkk1FPlP

System information:

  • p5 release (version number or latest commit): newest
  • Python version:3.7
  • Operating system: windows 10

Additional context Add any other context about the problem here.

yonghuming avatar Dec 11 '20 04:12 yonghuming

Thank you for submitting your first issue to p5py

github-actions[bot] avatar Dec 11 '20 04:12 github-actions[bot]

+1 seeing same behavior on 2017 MacBook Pro

aaronpenne avatar Dec 22 '20 05:12 aaronpenne

I think this issue will be solved once skia is implimented #212

ReneTC avatar Dec 22 '20 08:12 ReneTC

skia

opengl is powerful, why p5py so slow? pygame have better experence with similar code, also arcade. mabye there are ways to figure it still use opengl and glfw

yonghuming avatar Jan 01 '21 09:01 yonghuming

skia use glfw

yonghuming avatar Jan 01 '21 09:01 yonghuming

You can try the new experimental renderer or visit #357. I tried the above example and it runs fine for skia

tushar5526 avatar Aug 07 '22 19:08 tushar5526