Draw a squiggly line from p1 to p2.
(
self,
p1: point_like,
p2: point_like,
breadth=2,
)
| 15151 | return p2 |
| 15152 | |
| 15153 | def draw_squiggle( |
| 15154 | self, |
| 15155 | p1: point_like, |
| 15156 | p2: point_like, |
| 15157 | breadth=2, |
| 15158 | ) -> Point: |
| 15159 | """Draw a squiggly line from p1 to p2.""" |
| 15160 | p1 = Point(p1) |
| 15161 | p2 = Point(p2) |
| 15162 | S = p2 - p1 # vector start - end |
| 15163 | rad = abs(S) # distance of points |
| 15164 | cnt = 4 * int(round(rad / (4 * breadth), 0)) # always take full phases |
| 15165 | if cnt < 4: |
| 15166 | raise ValueError("points too close") |
| 15167 | mb = rad / cnt # revised breadth |
| 15168 | matrix = Matrix(util_hor_matrix(p1, p2)) # normalize line to x-axis |
| 15169 | i_mat = ~matrix # get original position |
| 15170 | k = 2.4142135623765633 # y of draw_curve helper point |
| 15171 | |
| 15172 | points = [] # stores edges |
| 15173 | for i in range(1, cnt): |
| 15174 | if i % 4 == 1: # point "above" connection |
| 15175 | p = Point(i, -k) * mb |
| 15176 | elif i % 4 == 3: # point "below" connection |
| 15177 | p = Point(i, k) * mb |
| 15178 | else: # else on connection line |
| 15179 | p = Point(i, 0) * mb |
| 15180 | points.append(p * i_mat) |
| 15181 | |
| 15182 | points = [p1] + points + [p2] |
| 15183 | cnt = len(points) |
| 15184 | i = 0 |
| 15185 | while i + 2 < cnt: |
| 15186 | self.draw_curve(points[i], points[i + 1], points[i + 2]) |
| 15187 | i += 2 |
| 15188 | return p2 |
| 15189 | |
| 15190 | # ============================================================================== |
| 15191 | # Shape.insert_text |
nothing calls this directly
no test coverage detected