py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

Py5Shape's `get_children()` method should return `[]` when there are no children #501

Closed hx2A closed 1 month ago

hx2A commented 1 month ago

Both for empty GROUP shapes and non-GROUP shapes.

hx2A commented 1 month ago

From discussion #500 #499

hx2A commented 1 month ago

@villares , can you provide some example code that reproduces this bug?

I believe this is an easy fix, but when I was testing my fix, I realized my test code could not reproduce the problem when I didn't include my code change.

villares commented 1 month ago

The shapely experiment I posted (without an if guard) sometimes produced this I think (like when overlapping all circles). I'm away from the computer, but I'll try to remember providing some other shorter code to reproduce this!

hx2A commented 1 month ago

The shapely experiment I posted (without an if guard) sometimes produced this I think (like when overlapping all circles). I'm away from the computer, but I'll try to remember providing some other shorter code to reproduce this!

I thought of that, and already tried to reproduce it with that code. Then I realized I could try sometime simple:

def setup():
    s = py5.create_shape()
    print(s.get_children())

That did reproduced it. I'll merge the fix now.

villares commented 1 month ago

Ha! This is exactly what I wrote when I got back to the computer! Cool!