MCPcopy Create free account
hub / github.com/KlingAIResearch/GameFactory / draw_rounded_rectangle

Function draw_rounded_rectangle

visualize.py:58–71  ·  view source on GitHub ↗
(image, top_left, bottom_right, color, radius=10, alpha=0.5)

Source from the content-addressed store, hash-verified

56
57# 绘制圆角矩形
58def draw_rounded_rectangle(image, top_left, bottom_right, color, radius=10, alpha=0.5):
59 overlay = image.copy()
60 x1, y1 = top_left
61 x2, y2 = bottom_right
62
63 cv2.rectangle(overlay, (x1 + radius, y1), (x2 - radius, y2), color, -1)
64 cv2.rectangle(overlay, (x1, y1 + radius), (x2, y2 - radius), color, -1)
65
66 cv2.ellipse(overlay, (x1 + radius, y1 + radius), (radius, radius), 180, 0, 90, color, -1)
67 cv2.ellipse(overlay, (x2 - radius, y1 + radius), (radius, radius), 270, 0, 90, color, -1)
68 cv2.ellipse(overlay, (x1 + radius, y2 - radius), (radius, radius), 90, 0, 90, color, -1)
69 cv2.ellipse(overlay, (x2 - radius, y2 - radius), (radius, radius), 0, 0, 90, color, -1)
70
71 cv2.addWeighted(overlay, alpha, image, 1 - alpha, 0, image)
72
73# 在帧上绘制按键
74def draw_keys_on_frame(frame, keys, key_size=(80, 50), spacing=20, bottom_margin=30):

Callers 1

draw_keys_on_frameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected