Draw a zig-zagged line from p1 to p2.
(
self,
p1: point_like,
p2: point_like,
breadth: float = 2,
)
| 15122 | return self.draw_polyline([q.ul, q.ll, q.lr, q.ur, q.ul]) |
| 15123 | |
| 15124 | def draw_zigzag( |
| 15125 | self, |
| 15126 | p1: point_like, |
| 15127 | p2: point_like, |
| 15128 | breadth: float = 2, |
| 15129 | ) -> Point: |
| 15130 | """Draw a zig-zagged line from p1 to p2.""" |
| 15131 | p1 = Point(p1) |
| 15132 | p2 = Point(p2) |
| 15133 | S = p2 - p1 # vector start - end |
| 15134 | rad = abs(S) # distance of points |
| 15135 | cnt = 4 * int(round(rad / (4 * breadth), 0)) # always take full phases |
| 15136 | if cnt < 4: |
| 15137 | raise ValueError("points too close") |
| 15138 | mb = rad / cnt # revised breadth |
| 15139 | matrix = Matrix(util_hor_matrix(p1, p2)) # normalize line to x-axis |
| 15140 | i_mat = ~matrix # get original position |
| 15141 | points = [] # stores edges |
| 15142 | for i in range(1, cnt): |
| 15143 | if i % 4 == 1: # point "above" connection |
| 15144 | p = Point(i, -1) * mb |
| 15145 | elif i % 4 == 3: # point "below" connection |
| 15146 | p = Point(i, 1) * mb |
| 15147 | else: # ignore others |
| 15148 | continue |
| 15149 | points.append(p * i_mat) |
| 15150 | self.draw_polyline([p1] + points + [p2]) # add start and end points |
| 15151 | return p2 |
| 15152 | |
| 15153 | def draw_squiggle( |
| 15154 | self, |
nothing calls this directly
no test coverage detected