【问题标题】:Is it a Manim bug or am I doing something wrong such that simple square fill_color fails?是 Manim 错误还是我做错了什么,导致简单的正方形 fill_color 失败?
【发布时间】:2022-11-07 21:25:57
【问题描述】:

这是我的代码。我希望两个正方形都被填充为绿色,但只有 square1 是正确的。运行 Windows 10 和 manim community v0.15.2。这是一个manim错误吗? square2 的注释显示了如何规避该错误。

from manim import *
class MovingTriangle(Scene):
  def construct(self):
    square1 = Square(side_length=1,color=RED,fill_color=RED, fill_opacity=1)
    square1.color = GREEN
    square1.fill_color = GREEN
    square1.fill_opacity = 1
    square1.stroke_color = GREEN

    square2 = Square(side_length=1) # if parms for any color added in this constructor then square2 would work (fill green)
    square2.color = GREEN
    square2.fill_color = GREEN
    square2.fill_opacity = 1
    square2.stroke_color = GREEN
    square2.next_to(square1, RIGHT)
    self.add(square1, square2)
    self.wait()

【问题讨论】:

    标签: manim


    【解决方案1】:

    我不会真的称之为错误,但我同意这种行为有点出乎意料。不支持仅通过设置fill_color 属性来设置mobject 的颜色;在 mobject 的颜色为实际上渲染时发生了变化(最明显的是对update_rgbas_array的调用)。

    目前最好在构造函数中设置颜色,或者使用专用的set_colorset_fillset_strokeset_style 方法。

    【讨论】:

      【解决方案2】:

      找到了解决方案。您需要显式设置opacity = 1.0,因为默认情况下大多数VMobjects 没有填充不透明度。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-04
      • 2012-06-24
      • 2010-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多