Layout Creation
We define the configuration of the page layout as follows , in a way we are telling the pixel density of the page wit the following
Some constants related to the creation of a page are as follows
Utility functions
Manim library accepts its coordinate values in a system that points its origin to the center of the page, we have to convert it to the top left orgin system, we use the following method for that purpose
paint_pixels
paint_pixels (px, axis='x', system='manim')
provide the distance value in pixels , the axis (x or y)
Similarly to place a text character or word in the top left coordinate system we have the following method
place_text_paint
place_text_paint (text, px, py, font_size=24, color=ManimColor('#000000'), weight='NORMAL', anchor=array([-1., 1., 0.]), line_spacing=1.2, **kwargs)
To draw a straight line from a point a to b
make_line_paint
make_line_paint (start_px, end_px, color=ManimColor('#000000'), stroke_width=42, system='manim')
provide the start point, end point and the axis(x or y ) that you want to draw the straight line in.
The following is a slightly complicated method used for generating the line items
create_item_group
create_item_group (item, item_number, row_x, row_y, row_width, row_height, draw_rect=False)
The invoice headers are generated using the following
generate_header_specs_from_invoice
generate_header_specs_from_invoice (invoice, frame_number=0)
Main Scene class
InvoiceScene
InvoiceScene (frame_number=0, **kwargs)
*A Scene is the canvas of your animation.
The primary role of :class:Scene
is to provide the user with tools to manage mobjects and animations. Generally speaking, a manim script consists of a class that derives from :class:Scene
whose :meth:Scene.construct
method is overridden by the user’s code.
Mobjects are displayed on screen by calling :meth:Scene.add
and removed from screen by calling :meth:Scene.remove
. All mobjects currently on screen are kept in :attr:Scene.mobjects
. Animations are played by calling :meth:Scene.play
.
A :class:Scene
is rendered internally by calling :meth:Scene.render
. This in turn calls :meth:Scene.setup
, :meth:Scene.construct
, and :meth:Scene.tear_down
, in that order.
It is not recommended to override the __init__
method in user Scenes. For code that should be ran before a Scene is rendered, use :meth:Scene.setup
instead.*
Type | Default | Details | |
---|---|---|---|
frame_number | int | 0 | Add frame_number parameter |
kwargs | VAR_KEYWORD |
with custom data path
load_json_data_source
load_json_data_source (data_source_path=None, data_source_url=None)
*Load JSON data from various sources.
Args: data_source_path (str, optional): Path to local JSON file data_source_url (str, optional): URL to remote JSON endpoint
Returns: dict/list: Loaded JSON data
Raises: FileNotFoundError: If local file doesn’t exist requests.RequestException: If remote request fails json.JSONDecodeError: If JSON parsing fails*
InvoiceSceneWithCustomData
InvoiceSceneWithCustomData (frame_number=0, custom_data=None, **kwargs)
*A Scene is the canvas of your animation.
The primary role of :class:Scene
is to provide the user with tools to manage mobjects and animations. Generally speaking, a manim script consists of a class that derives from :class:Scene
whose :meth:Scene.construct
method is overridden by the user’s code.
Mobjects are displayed on screen by calling :meth:Scene.add
and removed from screen by calling :meth:Scene.remove
. All mobjects currently on screen are kept in :attr:Scene.mobjects
. Animations are played by calling :meth:Scene.play
.
A :class:Scene
is rendered internally by calling :meth:Scene.render
. This in turn calls :meth:Scene.setup
, :meth:Scene.construct
, and :meth:Scene.tear_down
, in that order.
It is not recommended to override the __init__
method in user Scenes. For code that should be ran before a Scene is rendered, use :meth:Scene.setup
instead.*