Skip to content

Context access inside Shape implementation #1489

@renesat

Description

@renesat

Problem

I am trying to implement some vector drawing with ratatui, but I face problem. The ratatui::widgets::canvas::Line method can't draw a line if one of the points is outside the window. In theory I can calculate the intersection and draw a shorter line, but I need to know the resolution from Shape. get_point doesn't help because it just returns none if the point is outside. Also context is a private field and I don't have access to the required fields.

Solution

I see few solutions:

  • Public access to context in Painter.
  • Additional methods like resolution and context bounds
  • New property for widgets that need context

Alternatives

I can use context before calling draw or draw without shape implementation, but it doesn't look consistent.

Additional context

I can try to implement some of the solution, but I am not sure which way is better

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions