MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / drawLinesBetweenPoints

Function drawLinesBetweenPoints

src/gamesbyexample/bouncinglines.py:115–128  ·  view source on GitHub ↗

Prints a line of characters between the specified points.

(points, character)

Source from the content-addressed store, hash-verified

113
114
115def drawLinesBetweenPoints(points, character):
116 """Prints a line of characters between the specified points."""
117 for i, point in enumerate(points):
118 pointA = point
119 if i == len(points) - 1:
120 # The last point draws a line to the first point:
121 pointB = points[0]
122 else:
123 # Draw the line to the next point:
124 pointB = points[i + 1]
125 # Loop over every x, y point from pointA to pointB:
126 for x, y in line(pointA[X], pointA[Y], pointB[X], pointB[Y]):
127 bext.goto(x, y)
128 print(character, end='')
129
130
131def line(x1, y1, x2, y2):

Callers 1

mainFunction · 0.85

Calls 1

lineFunction · 0.70

Tested by

no test coverage detected