Skip to content

Top-down Rendering #8

@qiumuyang

Description

@qiumuyang

Current Implementation renders nested objects from children to parents. The parent's size cannot be determined until all children are rendered except for the FixedContainer object.

If we organize the parent-child relationship in a tree, we now render the tree from children to parents, i.e. bottom-up rendering. It works well until we need to render the root object to any size. Under such circumstances, we need to render the tree from parents to children, i.e. top-down rendering. Parents determine the desired size of children, and children render themselves to the desired size.

To support top-down rendering, we maybe need to add a new method to RenderObject:

def render_to(self, width: int, height: int) -> RenderImage:
    """Render the object to a specific size.
    
    Default implementation is to render the object as usual and resize the
    result to the desired size.
    """
    return self.render().resize(width, height)

Further details are to be discussed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions