Example #1
0
 def __get_bezier_middle(self, bezier: QPainterPath) -> QPointF:
     """
     Get the point in the middle of a bezier curve.
     """
     percent_middle = bezier.percentAtLength(
         bezier.length() / 2)
     return bezier.pointAtPercent(percent_middle)
Example #2
0
 def __get_bezier_middle_angle(self, bezier: QPainterPath):
     """
     Get the angle in the middle of a bezier curve.
     """
     percent_middle = bezier.percentAtLength(
         bezier.length() / 2)
     return -math.radians(
         bezier.angleAtPercent(percent_middle))
Example #3
0
def count_perimeter(outline_path: QPainterPath, ratio: int = 1) -> float:
    """
    :param outline_path: 轮廓的像素的矩阵
    :param ratio: 图像的分辨率 以米为单位
    :return: float类型的面积
    """
    percent = QPainterPath.percentAtLength(outline_path, 1000)
    length = 1000 / percent * ratio
    return length