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

Method drawInfoBox

Lib/pagebot/elements/views/pageview.py:653–678  ·  view source on GitHub ↗

Draw box with element info.

(self, e, px, py, pw, ph)

Source from the content-addressed store, hash-verified

651 e._restoreScale(self)
652
653 def drawInfoBox(self, e, px, py, pw, ph):
654 """Draw box with element info."""
655 style = dict(font=self.css('viewInfoFont'),
656 fontSize=self.css('viewInfoFontSize'),
657 leading=self.css('viewInfoLeading'),
658 textFill=color(0.1))
659 bs = self.context.newString(str(e), style=style)
660 tw, th = bs.textSize
661
662 # Padding in box and shadow offset.
663 Pd = 4
664
665 # Make info box outdent the element. Keeping shadow on the
666 # element top left corner.
667 tpx = px - Pd/2
668 tpy = py + e.h - th - Pd
669
670 # Tiny shadow
671 self.context.fill(color(0.3, 0.3, 0.3, 0.5))
672 self.context.stroke(noColor)
673 self.context.rect(tpx+Pd/2, tpy, tw+2*Pd, th+1.5*Pd)
674 # Frame
675 self.context.fill(self.css('viewInfoFill'))
676 self.context.stroke(color(0.3), w=pt(0.25))
677 self.context.rect(tpx, tpy, tw+2.5*Pd, th+1.5*Pd)
678 self.context.text(bs, (tpx+Pd, tpy+th))
679
680 def drawDimensions(self, px, py, pw, ph):
681 """Draws width and height measures."""

Callers 1

Calls 8

colorFunction · 0.90
ptFunction · 0.90
newStringMethod · 0.80
cssMethod · 0.45
fillMethod · 0.45
strokeMethod · 0.45
rectMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected