MCPcopy Create free account
hub / github.com/BIT-DataLab/Edit-Banana / polygon_to_geometry

Method polygon_to_geometry

modules/text/coord_processor.py:100–119  ·  view source on GitHub ↗

将多边形转换为 draw.io geometry 格式 Args: polygon: 四边形顶点坐标 Returns: dict: {"x", "y", "width", "height", "baseline_y", "rotation"}

(self, polygon: list[tuple[float, float]])

Source from the content-addressed store, hash-verified

98 return round(angle_deg, 1)
99
100 def polygon_to_geometry(self, polygon: list[tuple[float, float]]) -> dict:
101 """
102 将多边形转换为 draw.io geometry 格式
103
104 Args:
105 polygon: 四边形顶点坐标
106
107 Returns:
108 dict: {"x", "y", "width", "height", "baseline_y", "rotation"}
109 """
110 coords = self.normalize_polygon(polygon)
111
112 return {
113 "x": round(coords.x, 2),
114 "y": round(coords.y, 2),
115 "width": round(coords.width, 2),
116 "height": round(coords.height, 2),
117 "baseline_y": round(coords.baseline_y, 2),
118 "rotation": coords.rotation
119 }
120if __name__ == "__main__":
121 # 测试代码
122 processor = CoordProcessor(source_width=2000, source_height=1500)

Callers 2

process_imageMethod · 0.95
coord_processor.pyFile · 0.80

Calls 1

normalize_polygonMethod · 0.95

Tested by

no test coverage detected