craiyon logo

A technical drawing features three hexagons of varying sizes on a grid background, with dimensions "150 mm" and "55 mm" indicated, alongside mathematical formulas and geometric lines.

A technical drawing features three hexagons of varying sizes on a grid background, with dimensions "150 mm" and "55 mm" indicated, alongside mathematical formulas and geometric lines.

from PIL import Image, ImageDraw, ImageFont import math # === НАСТРОЙКИ === scale = 5 img_w, img_h = 1600, 800 start_x, start_y = 150, 250 length = 150 * scale width = 55 * scale # AF размеры afs = [30.5, 41.8, 36.6] def af_to_r(af): return af / 1.732 radii = [af_to_r(a)*scale for a in afs] gap = 6 * scale # === ЦЕНТРЫ === cx_center = 75 * scale cy = 27.5 * scale cx_left = cx_center - (radii[1] + radii[0] + gap) cx_right = cx_center + (radii[1] + radii[2] + gap) centers = [(cx_left, cy), (cx_center, cy), (cx_right, cy)] # === СОЗДАНИЕ ИЗОБРАЖЕНИЯ === img = Image.new("RGB", (img_w, img_h), "white") draw = ImageDraw.Draw(img) # === КОРПУС === draw.rectangle( [start_x, start_y, start_x + length, start_y + width], outline="black", width=3 ) # === ШЕСТИГРАННИК === def draw_hex(cx, cy, r): pts = [] for i in range(6): ang = math.pi / 3 * i x = start_x + cx + r * math.cos(ang) y = start_y + cy + r * math.sin(ang) pts.append((x, y)) draw.polygon(pts, outline="black", width=2) for c, r in zip(centers, radii): draw_hex(c[0], c[1], r) # === РАЗМЕРНЫЕ ЛИНИИ === # Длина 150 мм y_dim = start_y - 60 draw.line([start_x, y_dim, start_x + length, y_dim], fill="black", width=2) draw.line([start_x, start_y, start_x, y_dim], fill="black", width=2) draw.line([start_x + length, start_y, start_x + length, y_dim], fill="black", width=2) draw.text((start_x + length/2 - 40, y_dim - 25), "150 mm", fill="black") # Ширина 55 мм x_dim = start_x - 60 draw.line([x_dim, start_y, x_dim, start_y + width], Mehr sehen