def get_coordinate_labels(self, *numbers): result = VGroup() nudge = 0.1 * (DOWN + RIGHT) if len(numbers) == 0: numbers = range(-int(self.x_radius), int(self.x_radius) + 1) numbers += [ complex(0, y) for y in range(-int(self.y_radius), int(self.y_radius) + 1) ] for number in numbers: point = self.number_to_point(number) num_str = str(number).replace("j", "i") if num_str.startswith("0"): num_str = "0" elif num_str in ["1i", "-1i"]: num_str = num_str.replace("1", "") num_mob = TexMobject(num_str) num_mob.add_background_rectangle() num_mob.scale(self.number_scale_factor) if complex(number).imag != 0: vect = DOWN + RIGHT else: vect = DOWN + RIGHT num_mob.next_to(point, vect, SMALL_BUFF) result.add(num_mob) return result
def add_background_plane(self): background = NumberPlane(**self.plane_config).fade( self.background_fade_factor ) real_labels = VGroup(*[ TexMobject(str(x)).shift( background.num_pair_to_point((x, 0)) ) for x in range(-int(background.x_radius), int(background.x_radius)) ]) imag_labels = VGroup(*[ TexMobject("%di"%y).shift( background.num_pair_to_point((0, y)) ) for y in range(-int(background.y_radius), int(background.y_radius)) if y != 0 ]) for labels in real_labels, imag_labels: for label in labels: label.scale_in_place(self.background_label_scale_val) label.next_to(label.get_center(), DOWN+LEFT, buff = SMALL_BUFF) label.add_background_rectangle() background.add(labels) self.real_labels = real_labels self.imag_labels = imag_labels self.add(background) self.background = background
def get_coordinate_labels(self, *numbers): # TODO: Should merge this with the code from NumberPlane.get_coordinate_labels result = VGroup() nudge = 0.1*(DOWN+RIGHT) if len(numbers) == 0: numbers = range(-int(self.x_radius), int(self.x_radius)+1) numbers += [ complex(0, y) for y in range(-int(self.y_radius), int(self.y_radius)+1) ] for number in numbers: if number == complex(0, 0): continue point = self.number_to_point(number) num_str = str(number).replace("j", "i") if num_str.startswith("0"): num_str = "0" elif num_str in ["1i", "-1i"]: num_str = num_str.replace("1", "") num_mob = TexMobject(num_str) num_mob.add_background_rectangle() num_mob.scale_to_fit_height(self.written_coordinate_height) num_mob.next_to(point, DOWN+LEFT, SMALL_BUFF) result.add(num_mob) self.coordinate_labels = result return result
def get_transformer(self, **kwargs): transform_kwargs = dict(self.default_apply_complex_function_kwargs) transform_kwargs.update(kwargs) plane = self.plane self.prepare_for_transformation(plane) transformer = VGroup(plane, *self.transformable_mobjects) return transformer, transform_kwargs
def get_coordinate_labels(self, *numbers): result = VGroup() nudge = 0.1*(DOWN+RIGHT) if len(numbers) == 0: numbers = range(-int(self.x_radius), int(self.x_radius)) numbers += [ complex(0, y) for y in range(-int(self.y_radius), int(self.y_radius)) ] for number in numbers: point = self.number_to_point(number) if number == 0: num_str = "0" else: num_str = str(number).replace("j", "i") num = TexMobject(num_str) num.scale(self.number_scale_factor) num.shift(point-num.get_corner(UP+LEFT)+nudge) result.add(num) return result