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)
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
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
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
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
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
def bounding_quadrant(self): """Return a quadrant who contain the shape. Returns: Quadrant: The quadrant who contain the shape. """ from SVGVideoMaker.geo.point import Point2D radius = Point2D(self.rx, self.ry) mini = [coord - r for coord, r in zip(self.coordinates, radius)] maxi = [coord + r for coord, r in zip(self.coordinates, radius)] return Quadrant(mini, maxi)