Skip to content

Changing implementation of SVGMobject handle commands until the other API is done #3085

Open
@MrDiver

Description

@MrDiver

def handle_commands(self) -> None:
segment_class_to_func_map = {
se.Move: (self.start_new_path, ("end",)),
se.Close: (self.close_path, ()),
se.Line: (self.add_line_to, ("end",)),
se.QuadraticBezier: (
self.add_quadratic_bezier_curve_to,
("control", "end"),
),
se.CubicBezier: (
self.add_cubic_bezier_curve_to,
("control1", "control2", "end"),
),
}
for segment in self.path_obj:
segment_class = segment.__class__
func, attr_names = segment_class_to_func_map[segment_class]
points = [
_convert_point_to_3d(*segment.__getattribute__(attr_name))
for attr_name in attr_names
]
func(*points)
# Get rid of the side effect of trailing "Z M" commands.
if self.has_new_path_started():
self.resize_points(self.get_num_points() - 1)

This code is very confusing and i tested this with some if statements and there doesn't seem to be a performance difference. This issue is just to remind myself of commiting that code at some point.

Metadata

Metadata

Assignees

Labels

maintenancerefactoring, typos, removing clutter/dead code, and other code quality improvementsrefactorRefactor or redesign of existing code

Type

No type

Projects

Status

🆕 New

Relationships

None yet

Development

No branches or pull requests

Issue actions