gpt4 book ai didi

manim - 用 manim 代替 TeX 取消条款

转载 作者:行者123 更新时间:2023-12-04 15:35:04 30 4
gpt4 key购买 nike

你能画对角线/箭头/任何看起来像你在manim数学方程中抵消的东西吗?

enter image description here

最佳答案

最接近的定义是 Cross ,但这并不完全是您要找的,我喜欢用这个:

class Cancel(VGroup):
CONFIG = {
"line_kwargs": {"color":RED},
"buff_text": None,
"buff_line": 0.7,
}
def __init__(self,text,texmob=None,**kwargs):
digest_config(self,kwargs)
VGroup.__init__(self,**kwargs)

pre_coord_dl = text.get_corner(DL)
pre_coord_ur = text.get_corner(UR)
reference_line = Line(pre_coord_dl,pre_coord_ur)
reference_unit_vector = reference_line.get_unit_vector()
coord_dl = text.get_corner(DL) - text.get_center() - reference_unit_vector*self.buff_line
coord_ur = text.get_corner(UR) - text.get_center() + reference_unit_vector*self.buff_line
if texmob == None:
line = Line(coord_dl,coord_ur,**self.line_kwargs)
self.add(line)
else:
arrow = Arrow(coord_dl,coord_ur,**self.line_kwargs)
unit_vector = arrow.get_unit_vector()
if self.buff_text == None:
self.buff_text = get_norm((texmob.get_center()-texmob.get_critical_point(unit_vector))/2)*2
texmob.move_to(arrow.get_end()+unit_vector*self.buff_text)
self.add(arrow,texmob)


class CancelTerms(Scene):
def construct(self):
formula = TexMobject("f(x)",height=1)
cancel_formula = Cancel(formula,TexMobject("testa"))
self.add(formula,cancel_formula)

enter image description here

关于manim - 用 manim 代替 TeX 取消条款,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60050494/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com