Last active
October 14, 2024 20:47
-
-
Save uwezi/3b63822901851171aebe2caf477b7f35 to your computer and use it in GitHub Desktop.
[Reasonable Zoom Window] Keeping the stroke width outside of the zoomed frame. #manim #zoomedscene #frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
In a zoomed scene the outline stroke of the zoomed rectangular frame protrudes into the zoomed view at high magnification | |
''' | |
class ZoomPractice(ZoomedScene): | |
def construct(self): | |
ax = NumberPlane( | |
x_range=[0, 10, 5], | |
y_range=[0, 150, 50], | |
x_length=12, | |
y_length=12, | |
tips=False, | |
axis_config={"include_numbers": True, "include_ticks": True, "font_size": 60, "label_direction": DOWN * 1.25}, | |
y_axis_config={"label_direction": LEFT}, | |
background_line_style={ | |
"stroke_width": 1.5, | |
"stroke_opacity": 0 | |
}, | |
).set_color(WHITE).scale(0.45).move_to(ORIGIN) | |
zoomed_camera = self.zoomed_camera | |
zoomed_display = self.zoomed_display | |
frame = zoomed_camera.frame | |
visframe = always_redraw(lambda: | |
Rectangle(width=frame.width+2*3/100,height=frame.height+2*3/100,stroke_width=3,color=YELLOW).move_to(frame.get_center()) | |
) | |
frame.set_stroke(width=0) | |
self.add(visframe) | |
s_t = ax.plot(lambda x: ( 2*(x)**2) + (5 * x), x_range=[0, 6], use_smoothing=False, color=YELLOW, stroke_width=2) | |
self.add(ax) | |
self.play(Create(s_t), run_time=2) | |
self.wait(1) | |
self.activate_zooming() | |
self.wait(1) | |
self.play(self.zoomed_camera.frame.animate.scale(0.10)) | |
self.wait(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment