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

Method _get_childClipPath

Lib/pagebot/elements/clippath.py:50–88  ·  view source on GitHub ↗

Answers the clipping BezierPath, derived from the bouding box of child elements. >>> from pagebot.conditions import * >>> from pagebot import getContext >>> context = getContext() >>> context.newPage(w=500, h=500) >>> from pagebot.document import Docu

(self)

Source from the content-addressed store, hash-verified

48 clipPath = property(_get_clipPath, _set_clipPath)
49
50 def _get_childClipPath(self):
51 """Answers the clipping BezierPath, derived from the bouding box of
52 child elements.
53
54 >>> from pagebot.conditions import *
55 >>> from pagebot import getContext
56 >>> context = getContext()
57 >>> context.newPage(w=500, h=500)
58 >>> from pagebot.document import Document
59 >>> doc = Document(w=500, h=500, context=context)
60 >>> e = doc[1]
61 >>> e.childClipPath
62 <BezierPath 1>
63 >>> from pagebot.elements.element import Element
64 >>> e1 = Element(parent=e, x=0, y=0, w=50, h=80)
65 """
66 """
67 >>> #FIXME: we still need to implement boolean operations for Flat.
68 >>> len(e.childClipPath)
69 7
70 >>> e.childClipPath.points
71 [(50.0, 0.0), (500.0, 0.0), (500.0, 500.0), (0.0, 500.0), (0.0, 80.0), (50.0, 80.0), (50.0, 0.0)]
72 >>> e = Element(w=500, h=500, context=context)
73 >>> e1 = Element(parent=e, w=100, h=100, conditions=[Left2Left(), Top2Top()])
74 >>> e2 = Element(parent=e, w=100, h=100, conditions=(Left2Left(), Bottom2Bottom()))
75 >>> score = e.solve()
76 >>> e.childClipPath.points
77 [(100.0, 0.0), (500.0, 0.0), (500.0, 500.0), (0.0, 500.0), (0.0, 100.0), (100.0, 100.0), (100.0, 0.0)]
78 >>> e.childClipPath.__class__.__name__
79 'BezierPath'
80 """
81 path = self.PATH_CLASS(self.view.context)
82 path.rect(-self.ml, -self.mb, self.ml + self.w + self.mr, self.mb + self.h + self.mt)
83
84 for e in self.elements:
85 path = path.difference(e.childClipPath)
86
87 path.translate(self.xy)
88 return path
89
90 childClipPath = property(_get_childClipPath)
91

Callers

nothing calls this directly

Calls 3

rectMethod · 0.45
differenceMethod · 0.45
translateMethod · 0.45

Tested by

no test coverage detected