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

Method roundedRect

Lib/pagebot/contexts/basecontext/basecontext.py:1142–1165  ·  view source on GitHub ↗

Draw a rectangle in the canvas. This method is using the Bézier path as path to draw on. TODO: move to elements. >>> from pagebot import getContext >>> context = getContext() >>> context.roundedRect(pt(0), pt(0), pt(100), pt(100)) >>> context.rounded

(self, x, y, w, h, offset=25)

Source from the content-addressed store, hash-verified

1140 self.drawPath(path)
1141
1142 def roundedRect(self, x, y, w, h, offset=25):
1143 """Draw a rectangle in the canvas. This method is using the Bézier path
1144 as path to draw on.
1145
1146 TODO: move to elements.
1147
1148 >>> from pagebot import getContext
1149 >>> context = getContext()
1150 >>> context.roundedRect(pt(0), pt(0), pt(100), pt(100))
1151 >>> context.roundedRect(0, 0, 100, 100)
1152 """
1153 xPt, yPt, wPt, hPt, offsetPt = upt(x, y, w, h, offset)
1154 path = self.newPath()
1155 path.moveTo((xPt+offsetPt, yPt))
1156 path.lineTo((xPt+wPt-offsetPt, yPt))
1157 path.curveTo((xPt+wPt, yPt), (xPt+wPt, yPt), (xPt+wPt, yPt+offsetPt))
1158 path.lineTo((xPt+wPt, yPt+hPt-offsetPt))
1159 path.curveTo((xPt+wPt, yPt+hPt), (xPt+wPt, yPt+hPt), (xPt+wPt-offsetPt, yPt+hPt))
1160 path.lineTo((xPt+offsetPt, yPt+hPt))
1161 path.curveTo((xPt, yPt+hPt), (xPt, yPt+hPt), (xPt, yPt+hPt-offsetPt))
1162 path.lineTo((xPt, yPt+offsetPt))
1163 path.curveTo((xPt, yPt), (xPt, yPt), (xPt+offsetPt, yPt))
1164 self.closePath()
1165 self.drawPath(path)
1166
1167 # Mov.
1168

Callers

nothing calls this directly

Calls 7

newPathMethod · 0.95
closePathMethod · 0.95
drawPathMethod · 0.95
uptFunction · 0.90
moveToMethod · 0.45
lineToMethod · 0.45
curveToMethod · 0.45

Tested by

no test coverage detected