# Create a printable 6-piece puzzle (A4) as a PDF with a simple rocket illustration
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon, Circle
from matplotlib.transforms import Affine2D
import numpy as np
# A4 size in inches
width_in, height_in = 8.27, 11.69
dpi = 300
fig = plt.figure(figsize=(width_in, height_in), dpi=dpi)
ax = plt.axes([0,0,1,1])
ax.set_xlim(0,1)
ax.set_ylim(0,1)
ax.set_aspect('equal')
ax.axis('off')
# Helper to add shapes with grayscale fills for printer-friendly output
def gray(g):
# g in [0,1], 0=black,1=white
return str(g)
# Draw a simple rocket centered on the page
# Rocket body (oval-like polygon)
body_x = np.linspace(-0.14, 0.14, 50)
body_top = 0.62 + 0.28*np.sqrt(1 - (body_x/0.14)**2) # half-ellipse top
body_bottom = 0.38 - 0.18*np.sqrt(1 - (body_x/0.14)**2) # half-ellipse bottom
x_coords = np.concatenate([body_x, body_x[::-1]])
y_coords = np.concatenate([body_bottom, body_top[::-1]])
rocket_body = Polygon(np.c_[x_coords+0.5, y_coords], closed=True, facecolor=gray(0.92), edgecolor=gray(0.1), linewidth=2)
ax.add_patch(rocket_body)
# Nose cone (triangle)
nose = Polygon([[0.5, 0.9],[0.64,0.62],[0.36,0.62]], closed=True, facecolor=gray(0.85), edgecolor=gray(0.1), linewidth=2)
ax.add_patch(nose)
# Fins (triangles)
fin_left = Polygon([[0.36,0.45],[0.28,0.35],[0.36,0.38]], closed=True, facecolor=gray(0.8), edgecolor=gray(0.1), linewidth=2)
fin_right = Polygon([[0.64,0.45],[0.72,0.35],[0.64,0.38]], closed=True, facecolor=gray(0.8), edgecolor=gray(0.1), linewidth=2)
ax.add_patch(fin_left)
ax.add_patch(fin_right)
# Window
window = Circle((0.5,0.62), 0.06, facecolor=gray(0.98), edgecolor=gray(0.1), linewidth=2)
ax.add_patch(window)
inner = Circle((0.5,0.62), 0.035, facecolor=gray(0.85), edgecolor=gray(0.1), linewidth=1.5)
ax.add_patch(inner)
# Stripes
stripe1 = Polygon([[0.36,0.52],[0.64,0.52],[0.64,0.55],[0.36,0.55]], closed=True, facecolor=gray(0.88), edgecolor=gray(0.1), linewidth=1.5)
stripe2 = Polygon([[0.36,0.49],[0.64,0.49],[0.64,0.51],[0.36,0.51]], closed=True, facecolor=gray(0.9), edgecolor=gray(0.1), linewidth=1.5)
ax.add_patch(stripe1)
ax.add_patch(stripe2)
# Exhaust flames (stylized polygons)
flame1 = Polygon([[0.48,0.34],[0.52,0.34],[0.50,0.24]], closed=True, facecolor=gray(0.75), edgecolor=gray(0.1), linewidth=2)
flame2 = Polygon([[0.47,0.34],[0.50,0.34],[0.485,0.27]], closed=True, facecolor=gray(0.82), edgecolor=gray(0.1), linewidth=1.5)
flame3 = Polygon([[0.50,0.34],[0.53,0.34],[0.515,0.27]], closed=True, facecolor=gray(0.82), edgecolor=gray(0.1), linewidth=1.5)
ax.add_patch(flame1)
ax.add_patch(flame2)
ax.add_patch(flame3)
# Title
ax.text(0.5, 0.965, "6-Teile-Puzzle – Rakete", ha='center', va='top', fontsize=20, color=gray(0.1))
# Instructions
ax.text(0.5, 0.03, "Tipp: Ausdrucken, entlang der gestrichelten Linien schneiden, mischen und zusammensetzen.",
ha='center', va='bottom', fontsize=10, color=gray(0.2))
# Dashed cut lines for 3x2 grid (6 pieces)
for x in [1/3, 2/3]:
ax.plot([x, x], [0.06, 0.94], linestyle=(0,(6,6)), linewidth=2, color=gray(0.1))
for y in [0.5]:
ax.plot([0.06, 0.94], [y, y], linestyle=(0,(6,6)), linewidth=2, color=gray(0.1))
# Border margin
ax.plot([0.06,0.94,0.94,0.06,0.06],[0.06,0.06,0.94,0.94,0.06], linewidth=2.5, color=gray(0.1))
# Piece numbers in each cell
for row in range(2):
for col in range(3):
idx = row*3 + col + 1
x = (col+0.5)/3
y = 0.75 if row==1 else 0.25
ax.text(x, y, str(idx), ha='center', va='center', fontsize=28, color=gray(0.3), alpha=0.5)
# Scissor icons at margins (using text symbol)
ax.text(1/3, 0.955, "✂", ha='center', va='center', fontsize=14, color=gray(0.2))
ax.text(2/3, 0.955, "✂", ha='center', va='center', fontsize=14, color=gray(0.2))
ax.text(0.05, 0.5, "✂", ha='center', va='center', fontsize=14, rotation=90, color=gray(0.2))
ax.text(0.95, 0.5, "✂", ha='center', va='center', fontsize=14, rotation=90, color=gray(0.2))
# Save as PDF
output_path = "/mnt/data/6-Teile-Puzzle_Rakete.pdf"
plt.savefig(output_path, format="pdf")
plt.close(fig)
output_path