Untitled

mail@pastecode.io avatar
unknown
plain_text
13 days ago
1.5 kB
2
Indexable
Never
import cv2
import numpy as np

def create_canvas():
    return np.ones((500, 500, 3), dtype="uint8") * 255

def draw_center_circle(canvas, center, radius=10):
    cv2.circle(canvas, center, radius, (0, 0, 0), -1) 

def draw_expanding_squares(canvas, center, size):
    # Tüm kareleri çiz
    current_size = 50
    while current_size <= size:
        top_left = (center[0] - current_size // 2, center[1] - current_size // 2)
        bottom_right = (center[0] + current_size // 2, center[1] + current_size // 2)
        cv2.rectangle(canvas, top_left, bottom_right, (0, 0, 0), 4)
        current_size += 50

    # En son karenin köşelerine daireler çiz
    top_left = (center[0] - size // 2, center[1] - size // 2)
    bottom_right = (center[0] + size // 2, center[1] + size // 2)
    
    corner_points = [
        top_left,
        (top_left[0], bottom_right[1]),
        (bottom_right[0], top_left[1]),
        bottom_right
    ]
    for point in corner_points:
        cv2.circle(canvas, point, 8, (0, 255, 0), -1)  

def expand_squares():
    size = 50
    while True:
        canvas = create_canvas()
        center = (canvas.shape[1] // 2, canvas.shape[0] // 2)
        draw_center_circle(canvas, center)
        draw_expanding_squares(canvas, center, size)

        cv2.imshow("Canvas", canvas)

        key = cv2.waitKey(500)
        if key == 27: 
            break

        size += 50 

    cv2.destroyAllWindows()

if __name__ == "__main__":
    expand_squares()
Leave a Comment