Untitled

mail@pastecode.io avatar
unknown
plain_text
16 days ago
1.2 kB
4
Indexable
Never
import cv2
import math
import numpy as np

def draw_altıgen(image, center,radius, color):
    
    angles = [2 * math.pi / 6 * i for i in range(6)]
    
    points = [
        (int(center[0] + radius * math.cos(angle)), int(center[1] + radius * math.sin(angle)))
        for angle in angles
    ]
    

    for i in range(6):
        cv2.line(image, points[i], points[(i + 1) % 6], color, 2)

    for point in points:
        cv2.circle(image, point, 5, color, thickness=-1)

def altıgen():

    img_size = (800, 800, 3)
    
    color = (255, 124, 122)  # Yeşil renk
    
    center = (img_size[1] // 2, img_size[0] // 2)  # Altıgenlerin merkez noktası
    
    radii = [20 + i * (400 - 20) / 9 for i in range(10)]  # 10 farklı yarıçap
    
    while True:
        
        img = np.ones(img_size, dtype=np.uint8) * 255  # Beyaz arka plan
        for radius in radii:
            draw_altıgen(img, center,radius, color)
            cv2.imshow('altıgen', img)
            key = cv2.waitKey(500) & 0xFF
            if key == ord('q'):  # 'q' tuşuna basıldığında çıkış
                cv2.destroyAllWindows()
                return


altıgen()

Leave a Comment