diff --git a/manimlib/camera/camera.py b/manimlib/camera/camera.py index 2b9ab8ff..a1263ab0 100644 --- a/manimlib/camera/camera.py +++ b/manimlib/camera/camera.py @@ -230,10 +230,6 @@ class Camera(object): self.ctx.enable(moderngl.BLEND) else: self.ctx.disable(moderngl.BLEND) - self.ctx.blend_func = ( - moderngl.SRC_ALPHA, moderngl.ONE_MINUS_SRC_ALPHA, - # moderngl.ONE, moderngl.ONE - ) def set_ctx_depth_test(self, enable: bool = True) -> None: if enable: diff --git a/manimlib/config.py b/manimlib/config.py index cf8fbed0..d1d1cfa5 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -11,6 +11,7 @@ import yaml from manimlib.logger import log from manimlib.utils.config_ops import merge_dicts_recursively from manimlib.utils.init_config import init_customization +from manimlib.constants import FRAME_HEIGHT __config_file__ = "custom_config.yml" @@ -228,10 +229,10 @@ def insert_embed_line(file_name: str, scene_name: str, line_marker: str): n_spaces = get_indent(line) + 4 elif in_construct: if len(line.strip()) > 0 and get_indent(line) < n_spaces: - prev_line_num = index - 2 + prev_line_num = index - 1 break if prev_line_num is None: - prev_line_num = len(lines) - 2 + prev_line_num = len(lines) - 1 elif line_marker.isdigit(): # Treat the argument as a line number prev_line_num = int(line_marker) - 1 @@ -392,10 +393,11 @@ def get_configuration(args): monitors = get_monitors() mon_index = custom_config["window_monitor"] monitor = monitors[min(mon_index, len(monitors) - 1)] + aspect_ratio = config["camera_config"]["pixel_width"] / config["camera_config"]["pixel_height"] window_width = monitor.width if not (args.full_screen or custom_config["full_screen"]): window_width //= 2 - window_height = window_width * 9 // 16 + window_height = int(window_width / aspect_ratio) config["window_config"] = { "size": (window_width, window_height), } @@ -416,7 +418,9 @@ def get_configuration(args): def get_camera_configuration(args, custom_config): camera_config = {} camera_resolutions = get_custom_config()["camera_resolutions"] - if args.low_quality: + if args.resolution: + resolution = args.resolution + elif args.low_quality: resolution = camera_resolutions["low"] elif args.medium_quality: resolution = camera_resolutions["med"] @@ -439,6 +443,9 @@ def get_camera_configuration(args, custom_config): camera_config.update({ "pixel_width": width, "pixel_height": height, + "frame_config": { + "frame_shape": ((width / height) * FRAME_HEIGHT, FRAME_HEIGHT), + }, "fps": fps, }) diff --git a/manimlib/mobject/coordinate_systems.py b/manimlib/mobject/coordinate_systems.py index 09a84a97..7f42ec80 100644 --- a/manimlib/mobject/coordinate_systems.py +++ b/manimlib/mobject/coordinate_systems.py @@ -327,6 +327,7 @@ class CoordinateSystem(ABC): x_range = [*x_range, dx] rects = [] + x_range[1] = x_range[1] + dx xs = np.arange(*x_range) for x0, x1 in zip(xs, xs[1:]): if input_sample_type == "left": diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index 8a1a5bff..d5d37452 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -190,7 +190,6 @@ class Mobject(object): for mob in self.get_family(): for key in mob.data: mob.data[key] = mob.data[key][::-1] - self.refresh_unit_normal() return self def apply_points_function( @@ -634,13 +633,19 @@ class Mobject(object): to another mobject """ self.align_family(mobject) - for sm1, sm2 in zip(self.get_family(), mobject.get_family()): + family1 = self.get_family() + family2 = mobject.get_family() + for sm1, sm2 in zip(family1, family2): sm1.set_data(sm2.data) sm1.set_uniforms(sm2.uniforms) sm1.shader_folder = sm2.shader_folder sm1.texture_paths = sm2.texture_paths sm1.depth_test = sm2.depth_test sm1.render_primitive = sm2.render_primitive + # Make sure named family members carry over + for attr, value in list(mobject.__dict__.items()): + if isinstance(value, Mobject) and value in family2: + setattr(self, attr, family1[family2.index(value)]) self.refresh_bounding_box(recurse_down=True) self.match_updaters(mobject) return self diff --git a/manimlib/mobject/svg/drawings.py b/manimlib/mobject/svg/drawings.py index b8d58d21..64b6ca86 100644 --- a/manimlib/mobject/svg/drawings.py +++ b/manimlib/mobject/svg/drawings.py @@ -296,9 +296,11 @@ class Bubble(SVGMobject): CONFIG = { "direction": LEFT, "center_point": ORIGIN, - "content_scale_factor": 0.75, + "content_scale_factor": 0.7, "height": 5, "width": 8, + "max_height": None, + "max_width": None, "bubble_center_adjustment_factor": 1. / 8, "file_name": None, "fill_color": BLACK, @@ -313,8 +315,12 @@ class Bubble(SVGMobject): raise Exception("Must invoke Bubble subclass") SVGMobject.__init__(self, self.file_name, **kwargs) self.center() - self.stretch_to_fit_height(self.height) - self.stretch_to_fit_width(self.width) + self.set_height(self.height, stretch=True) + self.set_width(self.width, stretch=True) + if self.max_height: + self.set_max_height(self.max_height) + if self.max_width: + self.set_max_width(self.max_width) if self.direction[0] > 0: self.flip() if "direction" in kwargs: @@ -360,12 +366,9 @@ class Bubble(SVGMobject): return self def position_mobject_inside(self, mobject): - scaled_width = self.content_scale_factor * self.get_width() - if mobject.get_width() > scaled_width: - mobject.set_width(scaled_width) - mobject.shift( - self.get_bubble_center() - mobject.get_center() - ) + mobject.set_max_width(self.content_scale_factor * self.get_width()) + mobject.set_max_height(self.content_scale_factor * self.get_height() / 1.5) + mobject.shift(self.get_bubble_center() - mobject.get_center()) return mobject def add_content(self, mobject): @@ -377,15 +380,14 @@ class Bubble(SVGMobject): self.add_content(TexText(*text)) return self - def resize_to_content(self): - target_width = self.content.get_width() - target_width += max(MED_LARGE_BUFF, 2) - target_height = self.content.get_height() - target_height += 2.5 * LARGE_BUFF + def resize_to_content(self, buff=0.75): + width = self.content.get_width() + height = self.content.get_height() + target_width = width + min(buff, height) + target_height = 1.35 * (self.content.get_height() + buff) tip_point = self.get_tip() - self.stretch_to_fit_width(target_width) - self.stretch_to_fit_height(target_height) - self.move_tip_to(tip_point) + self.stretch_to_fit_width(target_width, about_point=tip_point) + self.stretch_to_fit_height(target_height, about_point=tip_point) self.position_mobject_inside(self.content) def clear(self): diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index d58def01..b21222be 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -770,6 +770,11 @@ class VMobject(Mobject): mob.get_unit_normal(recompute=True) return self + def reverse_points(self): + super().reverse_points() + self.refresh_unit_normal() + return self + # Alignment def align_points(self, vmobject: VMobject): if self.get_num_points() == len(vmobject.get_points()): diff --git a/manimlib/scene/scene.py b/manimlib/scene/scene.py index 73ae7d1d..2a29d7d1 100644 --- a/manimlib/scene/scene.py +++ b/manimlib/scene/scene.py @@ -837,7 +837,7 @@ class Scene(object): return if char == RESET_FRAME_KEY: - self.camera.frame.to_default_state() + self.play(self.camera.frame.animate.to_default_state()) elif char == "z" and modifiers == COMMAND_MODIFIER: self.undo() elif char == "z" and modifiers == COMMAND_MODIFIER | SHIFT_MODIFIER: diff --git a/manimlib/shaders/quadratic_bezier_stroke/vert.glsl b/manimlib/shaders/quadratic_bezier_stroke/vert.glsl index ed702e4f..e8eab203 100644 --- a/manimlib/shaders/quadratic_bezier_stroke/vert.glsl +++ b/manimlib/shaders/quadratic_bezier_stroke/vert.glsl @@ -29,6 +29,6 @@ void main(){ next_bp = position_point_into_frame(next_point); v_global_unit_normal = rotate_point_into_frame(unit_normal); - v_stroke_width = STROKE_WIDTH_CONVERSION * stroke_width; + v_stroke_width = STROKE_WIDTH_CONVERSION * stroke_width * frame_shape[1] / 8.0; v_color = color; } \ No newline at end of file