MCPcopy Create free account
hub / github.com/Layout-Parser/layout-parser / shift

Method shift

src/layoutparser/elements/layout_elements.py:730–745  ·  view source on GitHub ↗
(self, shift_distance=0)

Source from the content-addressed store, hash-verified

728 return self.__class__(x_1, y_1, x_2, y_2)
729
730 def shift(self, shift_distance=0):
731
732 if not isinstance(shift_distance, Iterable):
733 shift_x = shift_distance
734 shift_y = shift_distance
735 else:
736 assert (
737 len(shift_distance) == 2
738 ), "shift_distance should have 2 elements, one for x dimension and one for y dimension"
739 shift_x, shift_y = shift_distance
740
741 x_1 = self.x_1 + shift_x
742 y_1 = self.y_1 + shift_y
743 x_2 = self.x_2 + shift_x
744 y_2 = self.y_2 + shift_y
745 return self.__class__(x_1, y_1, x_2, y_2)
746
747 def scale(self, scale_factor=1):
748

Callers 1

test_rectangleFunction · 0.95

Calls

no outgoing calls

Tested by 1

test_rectangleFunction · 0.76