Yield starting points for streamlines. Trying points on the boundary first gives higher quality streamlines. This algorithm starts with a point on the mask corner and spirals inward. This algorithm is inefficient, but fast compared to rest of streamplot.
(shape)
| 630 | |
| 631 | |
| 632 | def _gen_starting_points(shape): |
| 633 | """Yield starting points for streamlines. |
| 634 | |
| 635 | Trying points on the boundary first gives higher quality streamlines. |
| 636 | This algorithm starts with a point on the mask corner and spirals inward. |
| 637 | This algorithm is inefficient, but fast compared to rest of streamplot. |
| 638 | """ |
| 639 | ny, nx = shape |
| 640 | xfirst = 0 |
| 641 | yfirst = 1 |
| 642 | xlast = nx - 1 |
| 643 | ylast = ny - 1 |
| 644 | x, y = 0, 0 |
| 645 | i = 0 |
| 646 | direction = 'right' |
| 647 | for i in range(nx * ny): |
| 648 | |
| 649 | yield x, y |
| 650 | |
| 651 | if direction == 'right': |
| 652 | x += 1 |
| 653 | if x >= xlast: |
| 654 | xlast -= 1 |
| 655 | direction = 'up' |
| 656 | elif direction == 'up': |
| 657 | y += 1 |
| 658 | if y >= ylast: |
| 659 | ylast -= 1 |
| 660 | direction = 'left' |
| 661 | elif direction == 'left': |
| 662 | x -= 1 |
| 663 | if x <= xfirst: |
| 664 | xfirst += 1 |
| 665 | direction = 'down' |
| 666 | elif direction == 'down': |
| 667 | y -= 1 |
| 668 | if y <= yfirst: |
| 669 | yfirst += 1 |
| 670 | direction = 'right' |