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

Method _applyScale

Lib/pagebot/elements/element.py:4723–4740  ·  view source on GitHub ↗

Internal method to apply the scale, if both *self.scaleX* and *self.scaleY* are set. Use this method paired with self._restoreScale(). The (x, y) answered as reversed scaled tuple, so drawing elements can still draw on "real size", while the other element is in scaled

(self, view, p)

Source from the content-addressed store, hash-verified

4721 self.view.context.rotate(-self.angle, center=(px+self.rx, py+self.ry))
4722
4723 def _applyScale(self, view, p):
4724 """Internal method to apply the scale, if both *self.scaleX* and
4725 *self.scaleY* are set. Use this method paired with
4726 self._restoreScale(). The (x, y) answered as reversed scaled tuple, so
4727 drawing elements can still draw on "real size", while the other element
4728 is in scaled mode."""
4729 sx = self.scaleX
4730 sy = self.scaleY
4731 sz = self.scaleZ
4732 p = point3D(p)
4733
4734 # Make sure these are value scale values.
4735 if sx and sy and sz and (sx != 1 or sy != 1 or sz != 1):
4736 self.view.context.save()
4737 view.scale = sx, sy
4738 # Scale point in 3 dimensions.
4739 p = (p[0] / sx, p[1] / sy, p[2] / sz)
4740 return p
4741
4742 def _restoreScale(self, view):
4743 """Reset graphics state from svaed scale mode. Make sure to match the

Callers 15

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

Calls 2

point3DFunction · 0.90
saveMethod · 0.45

Tested by

no test coverage detected