Question: I am tasked with making a 4 x 4 pyraminx and ive got column rotations and row rotations. The part i am stuck on is

I am tasked with making a 4x4 pyraminx and ive got column rotations and row rotations. The part i am stuck on is my draw function. When I run the code for some reason it leaves gaps in the triangles and doesnt fill them in. Please Help code provided below with picture.
def draw_triangle(surface, color, points):
pygame.draw.polygon(surface, color, points)
pygame.draw.polygon(surface, BLACK, points, 1)
def draw_pyraminx(screen, pyraminx):
center_x, center_y = WIDTH //2, HEIGHT //2+50
size =250
# Define the positions of the four faces
positions =[
(center_x, center_y - size *1), # Top
(center_x - size *1, center_y + size *0.3), # Left
(center_x + size *1, center_y + size *0.3), # Right
(center_x, center_y + size *0.2) # Bottom
]
face_labels =['Front (F)', 'Left (L)', 'Right (R)', 'Back (B)']
row_keys =[['1','2','3','4'],['Q','W','E','R'],['A','S','D','F'],['Z','X','C','V']]
col_keys =[['5','6','7','8'],['T','Y','U','I'],['G','H','J','K'],['B','N','M','L']]
font = pygame.font.Font(None,24)
for face_index, face in enumerate(pyraminx.faces):
x, y = positions[face_index]
# Draw face label
label = font.render(face_labels[face_index], True, BLACK)
screen.blit(label,(x - label.get_width()//2, y - size *0.2))
# Draw the smaller triangles
small_size = size //4
for i in range(4):
for j in range(4- i):
small_x = x +(j -(3- i)/2)* small_size
small_y = y + i * small_size * math.sqrt(3)/2
small_points =[
(small_x, small_y),
(small_x - small_size /2, small_y + small_size * math.sqrt(3)/2),
(small_x + small_size /2, small_y + small_size * math.sqrt(3)/2)
]
index = i *4-(i *(i -1)//2)+ j
if 0= index len(face):
color = COLOR_MAP.get(face[index], WHITE) # Use WHITE as fallback color
draw_triangle(screen, color, small_points)
else:
print(f"Warning: Invalid index {index} for face {face_index}")
# Draw row label
if i len(row_keys[face_index]):
key_label = font.render(row_keys[face_index][i], True, BLACK)
label_x = x +(3- i)* small_size *0.6
label_y = y + i * small_size * math.sqrt(3)/2
screen.blit(key_label, (label_x, label_y))
# Draw column labels
for j in range(4):
if j len(col_keys[face_index]):
key_label = font.render(col_keys[face_index][j], True, BLACK)
label_x = x +(j -1.5)* small_size
label_y = y - small_size *0.5
screen.blit(key_label, (label_x, label_y))
I am tasked with making a 4 x 4 pyraminx and ive

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!