MCPcopy Create free account
hub / github.com/PageBot/PageBot / translatePoint

Method translatePoint

Lib/pagebot/contexts/basecontext/basecontext.py:712–726  ·  view source on GitHub ↗

Simpler function to translate a point based on origin coordinates (`self._ox` and `self._oy`). TODO: merge with getTransformed.

(self, p)

Source from the content-addressed store, hash-verified

710 # Transformations.
711
712 def translatePoint(self, p):
713 """Simpler function to translate a point based on origin coordinates
714 (`self._ox` and `self._oy`).
715
716 TODO: merge with getTransformed.
717 """
718 x, y = point2D(upt(p))
719 x = self._ox + x
720
721 '''Because the origin is at the bottom, like in DrawBot and as opposed
722 to Flat, we need to subtract all vertical coordinates from the page
723 height before an object gets placed. In case of (bounding) boxes, we
724 also need to subtract the box height.'''
725 y = self.height - (self._oy + y)
726 return upt(x, y)
727
728 def transform(self, matrix, center=(0, 0)):
729 """Transform canvas over matrix t, e.g. (1, 0, 0, 1, dx, dy) to shift

Callers 6

imageMethod · 0.45
moveToMethod · 0.45
curveToMethod · 0.45
lineToMethod · 0.45
moveToMethod · 0.45
curveToMethod · 0.45

Calls 2

point2DFunction · 0.90
uptFunction · 0.90

Tested by

no test coverage detected