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

Method rect

Lib/pagebot/contexts/flatcontext/flatcontext.py:1032–1055  ·  view source on GitHub ↗

Calculates rectangle points by combining (x, y) with width and height, then runs the points through the affine transform and passes the coordinates to a Flat polygon to be rendered. NOTE: We are not using Flat.ellipse, transform won't work. Instead, we transform the

(self, x, y, w, h)

Source from the content-addressed store, hash-verified

1030 return shape
1031
1032 def rect(self, x, y, w, h):
1033 """Calculates rectangle points by combining (x, y) with width and
1034 height, then runs the points through the affine transform and passes
1035 the coordinates to a Flat polygon to be rendered.
1036
1037 NOTE: We are not using Flat.ellipse, transform won't work. Instead, we
1038 transform the points and then render as a polygon."""
1039 shape = self._getShape()
1040
1041 if shape is not None:
1042 x1 = upt(x + w)
1043 y1 = upt(y + h)
1044 p0 = upt(x, y)
1045 p1 = upt(x1, y)
1046 p2 = upt(x1, y1)
1047 p3 = upt(x, y1)
1048
1049 x, y = self.getTransformed(p0[0], p0[1])
1050 x1, y1 = self.getTransformed(p1[0], p1[1])
1051 x2, y2 = self.getTransformed(p2[0], p2[1])
1052 x3, y3 = self.getTransformed(p3[0], p3[1])
1053 coordinates = x, y, x1, y1, x2, y2, x3, y3
1054 r = shape.polygon(coordinates)
1055 self.page.place(r)
1056
1057 def oval(self, x, y, w, h):
1058 """Draws an oval in a rectangle, where (x, y) is the bottom left origin

Callers

nothing calls this directly

Calls 5

_getShapeMethod · 0.95
getTransformedMethod · 0.95
uptFunction · 0.90
placeMethod · 0.80
polygonMethod · 0.45

Tested by

no test coverage detected