sketchkit.ordering.Fu package

Submodules

sketchkit.ordering.Fu.compute_cost module

sketchkit.ordering.Fu.compute_cost.compute_T_junctions(txy1, txy2)[source]
sketchkit.ordering.Fu.compute_cost.compute_thetas(txy1, txy2, is_begin1, is_begin2)[source]
sketchkit.ordering.Fu.compute_cost.cost_individual(txy)[source]
sketchkit.ordering.Fu.compute_cost.cost_transition(txy1, txy2)[source]
sketchkit.ordering.Fu.compute_cost.curvatures(txy)[source]
sketchkit.ordering.Fu.compute_cost.dist_closest_points(txy1, txy2)[source]
sketchkit.ordering.Fu.compute_cost.line_segments_intersect(p1, p2, q1, q2)[source]
sketchkit.ordering.Fu.compute_cost.on_segment(p1, p2, p3)[source]
sketchkit.ordering.Fu.compute_cost.orientation(p1, p2, p3)[source]
sketchkit.ordering.Fu.compute_cost.process_end_points(txy1, txy2)[source]
sketchkit.ordering.Fu.compute_cost.remove_same_xy(txy)[source]
sketchkit.ordering.Fu.compute_cost.stroke_length(txy)[source]

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

class sketchkit.ordering.Fu.tsp_bnb.Node(trace, curr, weight_unary, weight_binary, n)[source]

Bases: object

lower_bound()[source]

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: Orderer

Implementation 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:

Sketch