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

Method drawElementOrigin

Lib/pagebot/elements/views/pageview.py:726–754  ·  view source on GitHub ↗
(self, e, origin)

Source from the content-addressed store, hash-verified

724 self.context.text(bs, (px+pw+2*S-tw/2, py+ph/2))
725
726 def drawElementOrigin(self, e, origin):
727 # Draw origin of the element
728 if not (self.showOrigin or e.showOrigin):
729 return
730
731 context = self.context
732 px, py, _ = pointOffset(e.origin, origin)
733 S = e.css('viewInfoOriginMarkerSize', pt(3))
734 fill = e.css('viewInfoOriginMarkerFill', noColor)
735 stroke = e.css('viewInfoOriginMarkerStroke', blackColor)
736 width = e.css('viewInfoOriginMarkerStrokeWidth', pt(0.25))
737
738 # Transparent fill, so we can see the marker on dark backgrounds.
739 context.fill(fill)
740 context.stroke(stroke, width)
741 context.oval(px-S, py-S, 2*S, 2*S)
742 context.line((px-S, py), (px+S, py))
743 context.line((px, py-S), (px, py+S))
744
745 if (self.showDimensions and e.isPage) or e.showDimensions:
746 msg = 'x: %s, y: %s, w: %s, h: %s' % (e.x, e.y, e.w, e.h)
747 style = dict(font=self.css('viewInfoFont'),
748 fontSize=self.css('viewInfoFontSize'),
749 leading=self.css('viewInfoLeading'),
750 textFill=color(0.1))
751 bs = context.newString(msg, style=style)
752
753 w, h = bs.textSize
754 context.drawString(bs, (px, py + S*1.5))
755
756 def drawMissingElementRect(self, e, origin):
757 """When designing templates and pages, this will draw a filled

Callers

nothing calls this directly

Calls 10

pointOffsetFunction · 0.90
ptFunction · 0.90
colorFunction · 0.90
newStringMethod · 0.80
cssMethod · 0.45
fillMethod · 0.45
strokeMethod · 0.45
ovalMethod · 0.45
lineMethod · 0.45
drawStringMethod · 0.45

Tested by

no test coverage detected