Untitled

mail@pastecode.io avatar
unknown
plain_text
7 days ago
1.4 kB
3
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, max_size):
    size = 50
    while size <= max_size:
        top_left = (center[0] - size // 2, center[1] - size // 2)
        bottom_right = (center[0] + size // 2, center[1] + size // 2)
        cv2.rectangle(canvas, top_left, bottom_right, (0, 0, 0), 3)  
        size += 50

    top_left = (center[0] - max_size // 2, center[1] - max_size // 2)
    bottom_right = (center[0] + max_size // 2, center[1] + max_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, 5, (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(100)
        if key == 27: 
            break

        size += 10  

    cv2.destroyAllWindows()

#fonksiyonu çağır    
expand_squares()
Leave a Comment