Example #1
0
    def get_svg(self):
        """Compute svg to string. Override default get_svg of group.

        Returns:
            str: A string who describe the svg.
        """
        if self.start_vb and self.end_vb:
            vb = (self.start_vb.coordinates, self.end_vb.coordinates)
        else:
            quadrant = Quadrant.empty_quadrant(2)
            for element in self.group:
                quadrant.update(element.bounding_quadrant())
            quadrant.inflate(1.1) # To see correctly border

            vb = quadrant.get_arrays()

        dimensions = [a - b for a, b in zip(vb[1], vb[0])]

        if any(d == 0.0 for d in dimensions):
            raise ValueError

        ratios = [a / b for a, b in zip(self.svg_dimensions, dimensions)]
        scale = min(ratios)
        if scale == 0.0:
            raise ValueError
        sk = 3 / scale
        return self.create_svg(view_box=vb, dimensions=dimensions, stroke_size=sk)
Example #2
0
    def bounding_quadrant(self):
        """Return a quadrant who contain the shape.

		Returns:
			Quadrant: The quadrant who contain the shape.
		"""
        box = Quadrant.empty_quadrant(2)
        for point in (self.start_point, self.end_point):
            box.add_point(point)

        # If points isn't in the same part of trigo circle, need to get max point
        if self.ea_anim - self.sa_anim > 90:
            sa_mod, ea_mod = self.sa_anim % 360, self.ea_anim % 360
            if sa_mod <= 0 < ea_mod:
                box.add_point(self.center_anim +
                              Point2D(self.radius_anim.coordinates[X], 0))
            if sa_mod <= 90 < ea_mod:
                box.add_point(self.center_anim +
                              Point2D(0, -self.radius_anim.coordinates[Y]))
            if sa_mod <= 180 < ea_mod:
                box.add_point(self.center_anim +
                              Point2D(-self.radius_anim.coordinates[X], 0))
            if sa_mod <= 270 < ea_mod:
                box.add_point(self.center_anim +
                              Point2D(0, self.radius_anim.coordinates[Y]))

        return box
Example #3
0
 def bounding_quadrant(self):
     """
     Return a quadrant who contain polygon
     :return: the quadrant who contain polygon
     """
     box = Quadrant.empty_quadrant(2)
     for point in self.points:
         box.add_point(point)
     return box
Example #4
0
    def bounding_quadrant(self):
        """Return a quadrant who contain the shape.

        Returns:
        	Quadrant: The quadrant who contain the shape.
        """
        quadrant = Quadrant.empty_quadrant(2)
        for point in self.anim_points:
            quadrant.add_point(point)
        return quadrant
Example #5
0
    def bounding_quadrant(self):
        """Return a quadrant who contain the shape.

		Returns:
			Quadrant: The quadrant who contain the shape.
		"""
        box = Quadrant.empty_quadrant(2)
        for point in (self.anim_point, self.middle_point, self.end_point):
            box.add_point(point)
        return box
Example #6
0
    def bounding_quadrant(self):
        """Return a quadrant who contain the shape.

        Returns:
        	Quadrant: The quadrant who contain the shape.
        """
        quadrant = Quadrant.empty_quadrant(2)
        for element in self.group:
            quadrant.update(element.bounding_quadrant())
        return quadrant