auto complete in #thonny #ide #python #shorts

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

import tkinter as tk
from math import sqrt

# Создаем главное окно
root = tk.Tk()
root.title("Квадрат с дугами и линиями")
canvas = tk.Canvas(root, width=600, height=600, bg='white')
canvas.pack()

# Размер квадрата
size = 300
center_x, center_y = 300, 300 # Центр холста

# Координаты углов квадрата
x1, y1 = center_x - size/2, center_y - size/2 # Левый нижний угол
x2, y2 = center_x + size/2, center_y + size/2 # Правый верхний угол

# Рисуем квадрат
canvas.create_rectangle(x1, y1, x2, y2, outline='black', width=2)

# Рисуем линии из левого нижнего угла
# 1. Линия к середине правой стороны
canvas.create_line(x1, y1, x2, center_y, fill='blue', width=2)

# 2. Линия к середине верхней стороны
canvas.create_line(x1, y1, center_x, y1, fill='green', width=2)

# 3. Линия к левому верхнему углу
canvas.create_line(x1, y1, x1, y2, fill='red', width=2)

# Рисуем дуги из левого нижнего угла
# 1. Дуга к правой верхней части (1/4 окружности)
radius = size * sqrt(2)/2 # Радиус = половина диагонали
canvas.create_arc(x1 - radius, y1 - radius,
x1 + radius, y1 + radius,
start=45, extent=90, outline='purple', width=2, style=tk.ARC)

# 2. Дуга к левой верхней части
canvas.create_arc(x1 - radius, y1 - radius,
x1 + radius, y1 + radius,
start=135, extent=90, outline='orange', width=2, style=tk.ARC)

# Добавляем подписи
canvas.create_text(x1 + 20, y1 - 20, text="Исходный угол", anchor='sw')
canvas.create_text(x2, center_y, text="Середина правой стороны", anchor='w')
canvas.create_text(center_x, y1, text="Середина верхней стороны", anchor='s')
canvas.create_text(x1, y2, text="Левый верхний угол", anchor='e')

root.mainloop()

димасиденко-гс
join shbcf.ru