본문 바로가기

Programming/Manim Lectures

[05-3-A] Common Methods

반응형

All shapes are created by inheriting VMobject. Since this VMobject is a class that inherits from Mobject, the shapes can use all Mobject methods and VMobject methods covered in the [05-1]Common methods of Mobject

 

Here, we will look at some of VMobject's common methods that are not covered in '[05-1]Common methods of Mobject', which are frequently used in shapes.

 

Summary of Frequently Used VMobject Method

  • set_fille: Fill the inside of a shape object with a given color
  • set_stroke: determines the color, thickness, and transparency of the shape outline
  • match_style: Change to the style of the target object
  • set_opacity: Change the transparency of the inner color and outline of the object to the specified value

set_fill

manimlib.mobject.types.vectorized_mobject.set_fill(self, color=None, opacity=None, family=True)

Fills the inner part of a shape object with a given color. 

 

Note that opacity=None=0 is the default value, so if you specify only the color value, it is transparent and the color is invisible. Therefore, opacity must be specified as a value between [0,1].

 

Parameters: color=None
    Color to fill shape. 
    You can specify constants, such as RED and BLUE, specified in constants.py, 
    or directly assign a color value such as "#236B8E".
    

Parameters: opacity=None
    Transparency. 
    0 is transparent, closer to 1 is opaque    

Parameters: family=True
    In the case of a group object composed of several sub-objects, 
    it is determined whether to paint all the sub-objects.

Returns:
    The object itself with set_fill applied

 

Usage

rect = Rectangle()
rect.set_fill(RED_C, opacity=1)

set_stroke

manimlib.mobject.types.vectorized_mobject.set_stroke(self, color=None, width=None, opacity=None, background=False, family=True)

Determine the colorthickness, and transparency of the shape outline.

 

Parameters: color=None
    Specifies the color of the outline.

Parameters: width=None
    Specifies the thickness of the outline. Generally, 3 is suitable.

Parameters:  opacity=None
    Transparency of the outline. 0 if transparent, 1 if opaque

Parameters:  background=False
    Eliminate the background lines of the outlines,
    so they match well when they overlap other objects (just like the background).

Parameters:  family=True
    In the case of a group object composed of several sub-objects,
    it is determined whether to reflect all the specified values for the sub-objects.

Returns:
    The object itself, whose outline properties have changed 

 

Usage

dot1.set_stroke(RED_E,2,background=True)

The difference between background=True and background=False can be seen by comparing the two shapes below.


Background=True on the left, background=False on the right


match_style

manimlib.mobject.types.vectorized_mobject.match_style(self, vmobject, family=True)

Match to the style of the target object.

 

The types of styles reflected are as follows.

 

  • fill_color
  • fill_opacity
  • stroke_color
  • stroke_width
  • stroke_opacity
  • background_stroke_color
  • background_stroke_width
  • background_stroke_opacity
  • sheen_factor
  • sheen_direction
  • background_image_file
Parameters: vmobject
    

Parameters:  family=True
    Target object. 
    After getting the style of this object with vmobject.get_style(), 
    it will change the style of the current object with this style.
    
Returns: The styled object itself
    

set_opacity

manimlib.mobject.types.vectorized_mobject.set_opacity(self, opacity, family=True)

Replaces the transparency of the object's inner color and outline with the specified values.

Parameters: opacity
    Transparency value. 
    [0,1] Sight value. 0 if transparent, 1 if opaque

Parameters:  family=True
    In the case of a group object composed of several sub-objects, 
    it is determined whether to reflect all the specified values for the sub-objects.

Returns: The styled object itself
    

Next: [05-3-B] Line series(1/2): Line/DashedLine

 

[05-3-B] Line series(1/2): Line/DashedLine

In Madam, there are six classes for drawing line-like shapes. All of them inherit the TipableVMobject class, so you can draw an arrow at the end of the line. Line(start, end): Create a line con..

infograph.tistory.com

Go To: [99] Table of Contents

반응형

'Programming > Manim Lectures' 카테고리의 다른 글

[05-3-C] Line : Arrow/Vector  (0) 2020.06.07
[05-3-B] Line series(1/2): Line/DashedLine  (0) 2020.06.07
[05-3]Shapes  (0) 2020.06.07
[05-2-C] TextMobject: for Equation and Text  (0) 2020.06.06
[05-2-B]TexMobject: for equation  (0) 2020.06.06