def get_dashed_rectangle(self, width, height): h1 = [ORIGIN, UP * height] w1 = [UP * height, UP * height + RIGHT * width] h2 = [UP * height + RIGHT * width, RIGHT * width] w2 = [RIGHT * width, ORIGIN] alpha = width / height divs = self.num_dashes n_h = int(divs / (2 * (alpha + 1))) n_w = int(alpha * n_h) dashedrectangle = VGroup() for n, l in zip([n_w, n_h], [[w1, w2], [h1, h2]]): for side in l: line = VMobject() line.set_points_as_corners(side) dashedrectangle.add( DashedVMobject( line, num_dashes=n, positive_space_ratio=self.positive_space_ratio, ).set_color(self.color).set_style(**self.line_config)) return [ dashedrectangle[0], dashedrectangle[3], dashedrectangle[1], dashedrectangle[2] ]
def __init__(self, *args, **kwargs): Line.__init__(self, *args, **kwargs) ps_ratio = self.positive_space_ratio num_dashes = self.calculate_num_dashes(ps_ratio) dashes = DashedVMobject(self, num_dashes=num_dashes, positive_space_ratio=ps_ratio) self.clear_points() self.add(*dashes)
def __init__(self, *args, **kwargs): #### EULERTOUR_INIT_START #### if not hasattr(self, "args"): self.args = serialize_args(args) if not hasattr(self, "config"): self.config = serialize_config({ **kwargs, }) #### EULERTOUR_INIT_START #### Line.__init__(self, *args, **kwargs) ps_ratio = self.positive_space_ratio num_dashes = self.calculate_num_dashes(ps_ratio) dashes = DashedVMobject(self, num_dashes=num_dashes, positive_space_ratio=ps_ratio) self.clear_points() self.add(*dashes) #### EULERTOUR_INIT_END #### register_mobject(self)