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

Method build

Lib/pagebot/elements/image2.py:81–126  ·  view source on GitHub ↗

Default drawing method just drawing the frame. Probably will be redefined by inheriting element classes.

(self, view, origin=ORIGIN, **kwargs)

Source from the content-addressed store, hash-verified

79 imageData = property(_get_imageData, _set_imageData)
80
81 def build(self, view, origin=ORIGIN, **kwargs):
82 """Default drawing method just drawing the frame. Probably will be
83 redefined by inheriting element classes."""
84 p = pointOffset(self.origin, origin)
85 p = self._applyScale(view, p)
86 px, py, _ = p = self._applyAlignment(p) # Ignore z-axis for now.
87 pt, pr, pb, pl = self.padding
88 self._applyRotation(view, p)
89 self.buildFrame(view, p) # Draw optional frame or borders.
90
91 # Let the view draw frame info for debugging, in case view.showFrame == True
92 # and self.isPage or if self.showFrame. Mark that we are drawing background here.
93 view.drawPageMetaInfoBackground(self, p)
94
95 if self.clipPath is not None:
96 # If there is a clipPath defined, use it.
97 clipPath = self.clipPath
98 else:
99 # Otherwise use self.box as clipRect when drawing the child elements.
100 clipPath = self.context.newPath()
101 # move to a point
102 clipPath.moveTo(upt(px+pl, py+pb))
103 # line to points of the clip rect.
104 clipPath.lineTo(upt(px+pl, py+pb+self.ph))
105 clipPath.lineTo(upt(px+pl+self.pw, py+pr+self.ph))
106 clipPath.lineTo(upt(px+pl+self.pw, py+pb))
107 clipPath.lineTo(upt(px+pl, py+pb))
108 # close the path
109 clipPath.closePath()
110
111 #self.context.fill((0, 1, 0))
112 #self.context.drawPath(clipPath)
113 self.context.save()
114 # set the path as a clipping path
115 #self.context.clipPath(clipPath)
116 # Build the child elements. Default this is the ImageData instance, but there
117 # may be other elemnents added too in any particular order.
118 self.buildChildElements(view, p)
119 self.context.restore()
120
121 # Let the view draw frame info for debugging, in case view.showFrame == True
122 # and self.isPage or if self.showFrame. Mark that we are drawing foreground here.
123 view.drawPageMetaInfo(self, p)
124 self._restoreRotation(view, p)
125 self._restoreScale(view)
126 view.drawElementInfo(self, origin) # Depends on flag 'view.showElementInfo'
127
128if __name__ == '__main__':
129 import doctest

Callers

nothing calls this directly

Calls 15

pointOffsetFunction · 0.90
uptFunction · 0.90
_applyScaleMethod · 0.80
_applyAlignmentMethod · 0.80
_applyRotationMethod · 0.80
buildFrameMethod · 0.80
buildChildElementsMethod · 0.80
_restoreRotationMethod · 0.80
_restoreScaleMethod · 0.80
newPathMethod · 0.45
moveToMethod · 0.45

Tested by

no test coverage detected