print("Hello world! - python.jsrun.net .")import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches
import numpy as np
import io
import base64
plt.switch_backend('agg')
plt.ioff()
fig, ax = plt.subplots(figsize=(8, 10))
ax.set_facecolor('white')
ax.set_aspect('equal')
ax.axis('off')
layers = [
{'y': 0.2, 'width': 0.8, 'height': 0.25},
{'y': 0.5, 'width': 0.65, 'height': 0.2},
{'y': 0.75, 'width': 0.5, 'height': 0.18}
]
for layer in layers:
rect = plt.Rectangle((0.5 - layer['width']/2, layer['y']),
layer['width'], layer['height'],
facecolor='none', edgecolor='black', linewidth=2)
ax.add_patch(rect)
for i in range(8):
x_pos = 0.5 - layer['width']/2 + layer['width']/7 * (i + 0.5)
circle = plt.Circle((x_pos, layer['y'] + layer['height']),
0.015, facecolor='none', edgecolor='black', linewidth=1.5)
ax.add_patch(circle)
verts = []
codes = []
segment_width = layer['width'] / 8
for i in range(7):
start_x = 0.5 - layer['width']/2 + segment_width * (i + 1)
verts.extend([
[start_x, layer['y']],
[start_x - segment_width/3, layer['y'] - 0.03],
[start_x + segment_width/3, layer['y'] - 0.03],
[start_x, layer['y']]
])
codes.extend([
Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4
])
path = Path(verts, codes)
patch = patches.PathPatch(path, facecolor='none', edgecolor='black', linewidth=1.2)
ax.add_patch(patch)
candle_width = 0.02
candle_height = 0.15
for i in range(3):
cx = 0.4 + i * 0.1
cy = layers[2]['y'] + layers[2]['height']
candle = plt.Rectangle((cx - candle_width/2, cy),
candle_width, candle_height,
facecolor='none', edgecolor='black', linewidth=1.5)
ax.add_patch(candle)
flame = plt.Circle((cx, cy + candle_height + 0.02),
0.025, facecolor='none', edgecolor='black', linewidth=1.2)
ax.add_patch(flame)
theta = np.linspace(0, 2*np.pi, 20)
r = 0.015 + 0.005 * np.sin(5*theta)
x = cx + r * np.cos(theta)
y = cy + candle_height + 0.02 + r * np.sin(theta)
ax.plot(x, y, 'k-', linewidth=0.8)
for layer in layers:
for i in range(5):
for j in range(3):
dot_x = 0.5 - layer['width']/4 + layer['width']/4 * i
dot_y = layer['y'] + layer['height']/4 * j
dot = plt.Circle((dot_x, dot_y), 0.01,
facecolor='none', edgecolor='black', linewidth=0.8)
ax.add_patch(dot)
plt.text(0.5, layers[1]['y'] + layers[1]['height']/2,
"th", fontsize=40,
fontfamily='serif', fontweight='bold',
ha='center', va='center')
buf = io.BytesIO()
plt.savefig(buf, format='svg', bbox_inches='tight', pad_inches=0.1)
plt.close(fig)