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

Method build

Lib/pagebot/elements/mask.py:39–74  ·  view source on GitHub ↗
(self, view, origin=ORIGIN, **kwargs)

Source from the content-addressed store, hash-verified

37 Polygon.__init__(self, points=points, w=w, h=h, **kwargs)
38
39 def build(self, view, origin=ORIGIN, **kwargs):
40 context = self.context # Get current context and builder.
41 b = context.b # This is a bit more efficient than self.b once we got context
42 p = pointOffset(self.origin, origin)
43 p = self._applyScale(view, p)
44 px, py, _ = p = self._applyAlignment(p) # Ignore z-axis for now.
45 self._applyRotation(view, p)
46
47 doDraw = False
48 if self.fill not in (None, noColor):
49 context.fill(self.fill)
50 doDraw = True
51
52 if self.stroke not in (None, noColor) and self.strokeWidth:
53 context.stroke(self.stroke)
54 context.strokeWidth(self.strokeWidth)
55 doDraw = True
56
57 if doDraw:
58 context.rect(px, py, self.w, self.h)
59
60 if self.drawAfter is not None: # Call if defined
61 self.drawAfter(self, view, p)
62
63 # Let the view draw frame info for debugging, in case view.showFrame ==
64 # True and self.isPage or if self.showFrame. Mark that we are drawing
65 # foreground here.
66 view.drawPageMetaInfo(self, p)
67
68 # Supposedly drawing outside rotation/scaling mode, so the origin of
69 # the element is visible.
70 view.drawElementOrigin(self, origin)
71
72 self._restoreRotation(view, p)
73 self._restoreScale(view)
74 view.drawElementInfo(self, origin) # Depends on flag 'view.showElementInfo'
75
76if __name__ == "__main__":
77 import doctest

Callers

nothing calls this directly

Calls 13

pointOffsetFunction · 0.90
_applyScaleMethod · 0.80
_applyAlignmentMethod · 0.80
_applyRotationMethod · 0.80
_restoreRotationMethod · 0.80
_restoreScaleMethod · 0.80
fillMethod · 0.45
strokeMethod · 0.45
strokeWidthMethod · 0.45
rectMethod · 0.45
drawPageMetaInfoMethod · 0.45
drawElementOriginMethod · 0.45

Tested by

no test coverage detected