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

Method drawCropMarks

Lib/pagebot/elements/views/mapview.py:866–913  ·  view source on GitHub ↗

If the show flag is set, then draw the cropmarks or page frame. >>> from pagebot.toolbox.units import mm >>> from pagebot import getContext >>> context = getContext() >>> from pagebot.elements.element import Element >>> from pagebot.style import getRootStyle

(self, e, origin)

Source from the content-addressed store, hash-verified

864 self._drawRegistrationMark(e, (x + w/2, y + h + cmSize), cmSize, cmStrokeWidth, False)
865
866 def drawCropMarks(self, e, origin):
867 """If the show flag is set, then draw the cropmarks or page frame.
868
869 >>> from pagebot.toolbox.units import mm
870 >>> from pagebot import getContext
871 >>> context = getContext()
872 >>> from pagebot.elements.element import Element
873 >>> from pagebot.style import getRootStyle
874 >>> from pagebot.elements.views.pageview import PageView
875 >>> style = getRootStyle() # Get default values
876 >>> e = Element()
877 >>> view = PageView(context=context, style=style)
878 >>> view.showCropMarks = True
879 >>> view.folds = [(mm(40), mm(60)),]
880 >>> view.drawCropMarks(e, pt(0, 0))
881 """
882 if (self.showCropMarks and e.isPage) or e.showCropMarks:
883 x, y = point2D(origin) # Ignore z-axus for now.
884 w, h = e.size
885 folds = self.css('folds')
886 cmDistance = self.css('viewCropMarkDistance') # From the side
887 cmSize = min(self.css('viewCropMarkSize', pt(32)), self.pl)
888 cmStrokeWidth = self.css('viewCropMarkStrokeWidth')
889
890 self.context.fill(noColor)
891 # For CMYK, draw all colors color(cmyk=1)).
892 self.context.stroke(registrationColor, w=cmStrokeWidth)
893 # Bottom left
894 self.context.line((x - cmDistance, y), (x - cmSize, y))
895 self.context.line((x, y - cmDistance), (x, y - cmSize))
896 # Bottom right
897 self.context.line((x + w + cmDistance, y), (x + w + cmSize, y))
898 self.context.line((x + w, y - cmDistance), (x + w, y - cmSize))
899 # Top left
900 self.context.line((x - cmDistance, y + h), (x - cmSize, y + h))
901 self.context.line((x, y + h + cmDistance), (x, y + h + cmSize))
902 # Top right
903 self.context.line((x + w + cmDistance, y + h), (x + w + cmSize, y + h))
904 self.context.line((x + w, y + h + cmDistance), (x + w, y + h + cmSize))
905 # Any fold lines to draw on the page?
906 if folds is not None:
907 for fx, fy in folds:
908 if fx is not None:
909 self.context.line((x + fx, y - cmDistance), (x + fx, y - cmSize))
910 self.context.line((x + fx, y + h + cmDistance), (x + fx, y + h + cmSize))
911 if fy is not None:
912 self.context.line((x - cmDistance, y + fy), (x - cmSize, y + fy))
913 self.context.line((x + w + cmDistance, y + fy), (x + w + cmSize, y + fy))
914
915 def drawColorBars(self, e, origin):
916 """Draw the color bars for offset printing color calibration.

Callers 1

drawPageMetaInfoMethod · 0.95

Calls 6

point2DFunction · 0.90
ptFunction · 0.90
cssMethod · 0.45
fillMethod · 0.45
strokeMethod · 0.45
lineMethod · 0.45

Tested by

no test coverage detected