I'm trying to make a sierpinsky triangle recursively, and i can generate all the triangles (via 3 line segments), however when i go to show my list, the graphics print separately. I saw on the documentation there's a graphics_array, which seems useful, but there weren't many examples and my tinkering with it was pretty much useless, especially since the "adjoin" feature is not yet implemented.
Also tried passing the graphics object "some_lines" to get filled by the function, but it doesn't seem like it accesses the reference. Code attached, maybe you can see a way I can plot all the lines within one sum of graphics, as was my initial attempt:
def draw_tri(some_lines, endpts): some_lines+=line([endpts[0], endpts[1]], color='blue') some_lines+=line([endpts[0], endpts[2]], color='blue') some_lines+=line([endpts[1], endpts[2]], color='blue') return
def get_mid(x,y): return (x+y)/2
def recurse_SG(some_lines, n, endpts): #graphics_sum = graphics_array([line([endpts[0], endpts[1]], color='blue')],3, 1) if(n==1): #graphics_sum[i]=draw_tri(endpts) draw_tri(some_lines, endpts) else: recurse_SG(some_lines, n-1, [endpts[0], (get_mid(endpts[0][0], endpts[1][0]), get_mid(endpts[0][1], endpts[1][1])), (get_mid(endpts[0][0], endpts[2][0]), get_mid(endpts[0][1], endpts[2][1]))]) recurse_SG(some_lines, n-1, [endpts[1], (get_mid(endpts[1][0], endpts[0][0]), get_mid(endpts[1][1], endpts[0][1])), (get_mid(endpts[1][0], endpts[2][0]), get_mid(endpts[1][1], endpts[2][1]))]) recurse_SG(some_lines, n-1, [endpts[2], (get_mid(endpts[2][0], endpts[0][0]), get_mid(endpts[2][1], endpts[0][1])), (get_mid(endpts[2][0], endpts[1][0]), get_mid(endpts[2][1], endpts[1][1]))])
show(some_lines, axes=false)