Args: segment: numpy array of shape Nx2, containing all the points in the polygon. color: color of the polygon. Refer to `matplotlib.colors` for a full list of formats that are accepted. edge_color: color of the polygon edges. Refer to `ma
(self, segment, color, edge_color=None, alpha=0.5)
| 1064 | return self.output |
| 1065 | |
| 1066 | def draw_polygon(self, segment, color, edge_color=None, alpha=0.5): |
| 1067 | """ |
| 1068 | Args: |
| 1069 | segment: numpy array of shape Nx2, containing all the points in the polygon. |
| 1070 | color: color of the polygon. Refer to `matplotlib.colors` for a full list of |
| 1071 | formats that are accepted. |
| 1072 | edge_color: color of the polygon edges. Refer to `matplotlib.colors` for a |
| 1073 | full list of formats that are accepted. If not provided, a darker shade |
| 1074 | of the polygon color will be used instead. |
| 1075 | alpha (float): blending efficient. Smaller values lead to more transparent masks. |
| 1076 | |
| 1077 | Returns: |
| 1078 | output (VisImage): image object with polygon drawn. |
| 1079 | """ |
| 1080 | if edge_color is None: |
| 1081 | # make edge color darker than the polygon color |
| 1082 | if alpha > 0.8: |
| 1083 | edge_color = self._change_color_brightness(color, brightness_factor=-0.7) |
| 1084 | else: |
| 1085 | edge_color = color |
| 1086 | edge_color = mplc.to_rgb(edge_color) + (1,) |
| 1087 | |
| 1088 | polygon = mpl.patches.Polygon( |
| 1089 | segment, |
| 1090 | fill=True, |
| 1091 | facecolor=mplc.to_rgb(color) + (alpha,), |
| 1092 | edgecolor=edge_color, |
| 1093 | linewidth=max(self._default_font_size // 15 * self.output.scale, 1), |
| 1094 | ) |
| 1095 | self.output.ax.add_patch(polygon) |
| 1096 | return self.output |
| 1097 | |
| 1098 | """ |
| 1099 | Internal methods: |
no test coverage detected