Draws the BezierPath. Scaled image is drawn on (x, y), in that order. Use self._bezierpath if path is omitted. PageBot function. NOTE: Flat uses native shape, Y-coordinates need to be inverted. TODO: update tests, counting contour points. TODO: add curve tests.
(self, path=None, p=None, sx=1, sy=None, fill=None,
stroke=None, strokeWidth=None)
| 389 | self._bezierpath.closePath() |
| 390 | |
| 391 | def drawPath(self, path=None, p=None, sx=1, sy=None, fill=None, |
| 392 | stroke=None, strokeWidth=None): |
| 393 | """Draws the BezierPath. Scaled image is drawn on (x, y), in that |
| 394 | order. Use self._bezierpath if path is omitted. PageBot function. |
| 395 | |
| 396 | NOTE: Flat uses native shape, Y-coordinates need to be inverted. |
| 397 | TODO: update tests, counting contour points. |
| 398 | TODO: add curve tests. |
| 399 | |
| 400 | >>> from pagebot import getContext |
| 401 | >>> context = getContext() |
| 402 | >>> path = context.newPath() |
| 403 | >>> path.points |
| 404 | () |
| 405 | >>> context.newPage(420, 420) |
| 406 | >>> # Property self.bezierpath creates a self._bezierpath BezierPath. |
| 407 | >>> len(context.bezierpath.points) |
| 408 | 0 |
| 409 | >>> context.moveTo((10, 10)) # moveTo and lineTo are drawing on context._bezierpath |
| 410 | >>> context.lineTo((110, 10)) |
| 411 | >>> context.lineTo((110, 110)) |
| 412 | >>> context.lineTo((10, 110)) |
| 413 | >>> context.closePath() |
| 414 | >>> #len(context.bezierpath.points) #5 |
| 415 | >>> #len(context.bezierpath.points) #5 |
| 416 | >>> context.fill((1, 0, 0)) |
| 417 | >>> context.drawPath(p=(0, 0)) # Draw self._bezierpath with various offsets |
| 418 | >>> context.drawPath(p=(200, 200)) |
| 419 | >>> context.drawPath(p=(0, 200)) |
| 420 | >>> context.drawPath(p=(200, 0)) |
| 421 | >>> context.saveImage('_export/DrawBotContext1.pdf') |
| 422 | >>> # Drawing directly on a path, created by context |
| 423 | >>> path = context.newPath() # Leaves current self._bezierpath untouched |
| 424 | >>> len(path.points) |
| 425 | 0 |
| 426 | >>> path.moveTo((10, 10)) # Drawing on context._bezierpath |
| 427 | >>> path.lineTo((110, 10)) |
| 428 | >>> path.lineTo((110, 110)) |
| 429 | >>> path.lineTo((10, 110)) |
| 430 | >>> path.lineTo((10, 10)) |
| 431 | >>> path.closePath() |
| 432 | >>> len(path) |
| 433 | 1 |
| 434 | >>> contour = path.contours[0] |
| 435 | >>> len(contour) |
| 436 | 5 |
| 437 | """ |
| 438 | |
| 439 | """ |
| 440 | FIXME: oval gives different results. |
| 441 | >>> context = getContext() |
| 442 | >>> path = context.newPath() |
| 443 | >>> path.oval(160-50, 160-50, 100, 100) # path.oval draws directly on the path |
| 444 | >>> #len(path.points) #6 |
| 445 | >>> context.fill((0, 0.5, 1)) |
| 446 | >>> context.drawPath(path, p=(0, 0)) # Draw self._bezierpath with various offsets |
| 447 | >>> context.drawPath(path, p=(200, 200)) |
| 448 | >>> context.drawPath(path, p=(0, 200)) |