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

Method _applyAlignment

Lib/pagebot/elements/element.py:4685–4709  ·  view source on GitHub ↗

Answers point `p` according to the alignment status in the css. TODO: handle other text alignments.

(self, p)

Source from the content-addressed store, hash-verified

4683 # Private alignment, scale and rotation functions.
4684
4685 def _applyAlignment(self, p):
4686 """Answers point `p` according to the alignment status in the css.
4687
4688 TODO: handle other text alignments.
4689 """
4690 px, py, pz = point3D(p)
4691
4692 # Horizontal.
4693 xAlign = self.xAlign
4694
4695 if xAlign == CENTER:
4696 px -= self.w / 2 / self.scaleX
4697 elif xAlign == RIGHT:
4698 px -= self.w / self.scaleX
4699
4700 # Vertical.
4701 yAlign = self.yAlign
4702
4703 if yAlign == MIDDLE:
4704 py -= self.h / 2 / self.scaleY
4705 elif yAlign == TOP:
4706 py -= self.h / self.scaleY
4707
4708 # Currently no alignment in z-axis implemented
4709 return px, py, pz
4710
4711 def _applyRotation(self, view, p):
4712 """Apply the rotation for angle, where (mx, my) is the rotation center."""

Callers 15

getPositionMethod · 0.95
build_indsMethod · 0.95
build_indsMethod · 0.80
build_indsMethod · 0.80
buildMethod · 0.80
build_indsMethod · 0.80
buildMethod · 0.80
buildMethod · 0.80
build_htmlMethod · 0.80
buildMethod · 0.80
buildMethod · 0.80
buildMethod · 0.80

Calls 1

point3DFunction · 0.90

Tested by

no test coverage detected