<h2>What’s CONFIG<aclass="headerlink"href="#what-s-config"title="Permalink to this headline">¶</a></h2>
<p><codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code> dictionary is a feature of manim, which facilitates the inheritance
and modification of parameters between parent and child classes.</p>
<divclass="line-block">
<divclass="line"><codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code> dictionary ‘s processing is in <codeclass="docutils literal notranslate"><spanclass="pre">manimlib/utils/config_ops.py</span></code></div>
<divclass="line">It can convert the key-value pairs in the <codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code> dictionary into class attributes and values</div>
</div>
<p>Generally, the first line of the <codeclass="docutils literal notranslate"><spanclass="pre">.__init__()</span></code> method in some basic class (<codeclass="docutils literal notranslate"><spanclass="pre">Mobject</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">Animation</span></code>,
etc.) will call this function <codeclass="docutils literal notranslate"><spanclass="pre">digest_config(self,</span><spanclass="pre">kwargs)</span></code> to convert both
the <codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code> dictionary and <codeclass="docutils literal notranslate"><spanclass="pre">kwargs</span></code> into attributes. Then it can be accessed
directly through <codeclass="docutils literal notranslate"><spanclass="pre">self.</span></code>, which simplifies the handling of inheritance between classes.</p>
<p><strong>An example</strong>:</p>
<p>There are many class inheritance relationships in <codeclass="docutils literal notranslate"><spanclass="pre">manimlib/mobject/geometry.py</span></code></p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># Line 279</span>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">Circle</span></code> class uses the key-value pair <codeclass="docutils literal notranslate"><spanclass="pre">"color":</span><spanclass="pre">RED</span></code> in the <codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code>
dictionary to add the attribute <codeclass="docutils literal notranslate"><spanclass="pre">self.color</span></code>.</p>
<p>At the same time, the <codeclass="docutils literal notranslate"><spanclass="pre">Dot</span></code> class also contains the key <codeclass="docutils literal notranslate"><spanclass="pre">color</span></code> in the
<codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code> dictionary, but the value is different. At this time, the priority will
modify the attribute <codeclass="docutils literal notranslate"><spanclass="pre">self.color</span></code> to <codeclass="docutils literal notranslate"><spanclass="pre">WHITE</span></code>.</p>
<h2>CONFIG nesting<aclass="headerlink"href="#config-nesting"title="Permalink to this headline">¶</a></h2>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code> dictionary supports nesting, that is, the value of the key is also
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code> dictionary of the <codeclass="docutils literal notranslate"><spanclass="pre">Camera</span></code> class contains many key-value pairs,
and this class needs to be instantiated in the <codeclass="docutils literal notranslate"><spanclass="pre">Scene</span></code> class. For more convenient
control, there is a special key-value pair in the Scene class <codeclass="docutils literal notranslate"><spanclass="pre">"camera_config":</span><spanclass="pre">{}</span></code>,
Its value is a dictionary, passed in as <codeclass="docutils literal notranslate"><spanclass="pre">kwargs</span></code> when initializing the <codeclass="docutils literal notranslate"><spanclass="pre">Camera</span></code> class
to modify the value of the properties of the <codeclass="docutils literal notranslate"><spanclass="pre">Camera</span></code> class.</p>
<p>So the nesting of the <codeclass="docutils literal notranslate"><spanclass="pre">CONFIG</span></code> dictionary <strong>essentially</strong> passes in the value as <codeclass="docutils literal notranslate"><spanclass="pre">kwargs</span></code>.</p>