Skip to content

Instantly share code, notes, and snippets.

@chiangqiqi
Created July 21, 2019 23:30
Show Gist options
  • Save chiangqiqi/5e139315cc1d2cccd8a006f4ea9fb234 to your computer and use it in GitHub Desktop.
Save chiangqiqi/5e139315cc1d2cccd8a006f4ea9fb234 to your computer and use it in GitHub Desktop.
2018gaokao
from manimlib.once_useful_constructs.region import Region
# PMobject 有 filter_out 方法,Circle 没有
class SquareToCircle(Scene):
def construct(self):
circle = Circle()
a = ORIGIN
pointB = Dot(point=np.array([-0.5042, 0.8636, 0]))
centerB = np.array([-0.7521, 0.4318,0])
semi_circleA = Arc(angle=np.pi, radius=1)
semi_circleB = Arc(angle = np.pi, radius = 0.4979,
arc_center=centerB)
semi_circleC = Arc(angle = np.pi, radius = 0.86722,
arc_center=np.array([0.2479, 0.4318,0]), start_angle=(-29.8622) * np.pi / 180 )
circleB = Circle(radius = 0.4979,
arc_center=centerB)
# half a circle
interior = Region(lambda x, y : (x**2 + y**2 < 1) & (x > 0))
pic = VGroup(semi_circleA, semi_circleB, semi_circleC, pointB)
square = Square()
square.flip(RIGHT)
square.rotate(-3 * TAU / 8)
circle.set_fill(PINK, opacity=0.5)
# self.play(FadeIn( semi_circleA), run_time=2)
# self.play(FadeIn(pic.scale(3)), run_time=2)
self.play(FadeIn(interior), run_time=2)
# self.play(Rotating(circle.scale(3)), run_time=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment