将多边形转换为 draw.io geometry 格式 Args: polygon: 四边形顶点坐标 Returns: dict: {"x", "y", "width", "height", "baseline_y", "rotation"}
(self, polygon: list[tuple[float, float]])
| 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 | } |
| 120 | if __name__ == "__main__": |
| 121 | # 测试代码 |
| 122 | processor = CoordProcessor(source_width=2000, source_height=1500) |
no test coverage detected