Skip to content

Refactor paths

Sergei Izmailov requested to merge sizmailov/extensions:refactor_paths into master

Overview:

Vector2d

  • 🆕 inkex.transforms.Vector2d represents Cartesian 2d vector (100% test coverage)

Path Commands

  • paths.Segment renamed to paths.PathCommand
  • paths.PathCommand hierarchy changed from line->Line->Segment to line->RelativePathCommand->PathCommand Line->AbsolutePathCommand->PathCommand
  • PathCommand is invariant with respect to any transformation (exception: Vect/Horz are converted to Line)
  • Implicit conversions between different path commands is prohibited
  • end_point and control_points methods are available to get last pen point or all control points of path command

Path and CubicSuperPath

  • segment of CubicSuperPath is extracted as CubicPath class. CubicPath is intended to replace list of "triplets of control points". To avoid immediate rewrite of "triplet"-based code .to_triplets() methods are available.
  • Operational transformations of Path are removed in favor of dedicated methods: Path() + (10,20) -> Path().translate(10, 20). Inplace transformation of Path requires inplace=True argument.
  • end_points and control_points properties are available for Path to avoid manual error-prone path traversals in user code.
  • CubicSuperPath is not derived from list
Edited by Martin Owens

Merge request reports