You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from p5 import *
star = None
def setup():
global star
size(3000, 1200)
star = PShape()
rect_shp = rect(300,300,100,100)
star.add_child(rect_shp)
def draw():
global star
background(125)
draw_shape(star)
I'm expecting to see a rectangle on my screen but I can't see anything.
I found that function draw_shape(shape, pos=(0, 0, 0)) defined in primitives.py (line 791) begins with the following statement:
p5.renderer.render(shape)
and only AFTER handles the children:
for child_shape in shape.children:
draw_shape(child_shape)
I think this behaviour is incorrect, the function should check the presence of children before calling p5.renderer.render(shape).
In fact, I tried to modify the function in this way:
def draw_shape(shape, pos=(0, 0, 0)):
if isinstance(shape, Geometry):
return
elif not len(shape.children):
p5.renderer.render(shape)
else:
for child_shape in shape.children:
draw_shape(child_shape)
and it worked: I was able to render my rectangle!
What do you think?
Am I using the custom PShape in the wrong manner or it is actually a bug?
Thank you!
The text was updated successfully, but these errors were encountered:
I tried to run the following code:
I'm expecting to see a rectangle on my screen but I can't see anything.
I found that function
draw_shape(shape, pos=(0, 0, 0))
defined inprimitives.py (line 791)
begins with the following statement:and only AFTER handles the children:
I think this behaviour is incorrect, the function should check the presence of children before calling
p5.renderer.render(shape)
.In fact, I tried to modify the function in this way:
and it worked: I was able to render my rectangle!
What do you think?
Am I using the custom PShape in the wrong manner or it is actually a bug?
Thank you!
The text was updated successfully, but these errors were encountered: