sketchkit.ordering.Fu package¶
Submodules¶
sketchkit.ordering.Fu.compute_cost module¶
sketchkit.ordering.Fu.direction module¶
- sketchkit.ordering.Fu.direction.determine_direction(prev: Point, start: Point, end: Point) bool[source]¶
Determine the direction of the line segment from prev to end. :param prev: The previous point. :type prev: Point :param start: The start point of the stroke. :type start: Point :param end: The end point of the stroke. :type end: Point
- Returns:
True if the direction is start to end, False otherwise.
- Return type:
bool
sketchkit.ordering.Fu.tsp_bnb module¶
Module contents¶
- class sketchkit.ordering.Fu.AnimatedDrawer(max_k: int = 4, w: float = 0.1111111, canvas_size: int = 800, canvas_color=(1, 1, 1), width: int = 4)[source]¶
Bases:
OrdererImplementation of Animated construction of line drawings.
This method analyzes stroke relationships, computes transition costs between strokes, and determines the optimal drawing order using a branch-and-bound algorithm.
- _animated_drawing(sketch: Sketch) Dict[str, Any][source]¶
Create an animated drawing from a static sketch.
- Parameters:
sketch – The static sketch to animate.
- Returns:
A dictionary containing the optimal solution (stroke order) and directions.
- Return type:
Dict
- _get_cost_bi(cost_bi, i, j)[source]¶
Get the cost between two strokes from a bidirectional cost matrix.
- Parameters:
cost_bi – Bidirectional cost matrix.
i – Index of the first stroke.
j – Index of the second stroke.
- Returns:
The cost between the two strokes.
- Return type:
float
- run(sketch: Sketch) Sketch[source]¶
Run the animated drawing algorithm to determine the optimal stroke order.
- Parameters:
sketch – Sketch object containing the static sketch to animate.
- Returns:
A Sketch object with ordered paths, where the order of paths corresponds to the optimized drawing sequence.
- Return type: