extend adds the line l to the contour, updating the ends map. It returns a boolean indicating whether the extension was successful.
(l line, ends endMap)
| 434 | // extend adds the line l to the contour, updating the ends map. It returns |
| 435 | // a boolean indicating whether the extension was successful. |
| 436 | func (c *contour) extend(l line, ends endMap) (ok bool) { |
| 437 | switch c.front() { |
| 438 | case l.p1: |
| 439 | c.backward = append(c.backward, l.p2) |
| 440 | delete(ends, l.p1) |
| 441 | ends[l.p2] = c |
| 442 | return true |
| 443 | case l.p2: |
| 444 | c.backward = append(c.backward, l.p1) |
| 445 | delete(ends, l.p2) |
| 446 | ends[l.p1] = c |
| 447 | return true |
| 448 | } |
| 449 | |
| 450 | switch c.back() { |
| 451 | case l.p1: |
| 452 | c.forward = append(c.forward, l.p2) |
| 453 | delete(ends, l.p1) |
| 454 | ends[l.p2] = c |
| 455 | return true |
| 456 | case l.p2: |
| 457 | c.forward = append(c.forward, l.p1) |
| 458 | delete(ends, l.p2) |
| 459 | ends[l.p1] = c |
| 460 | return true |
| 461 | } |
| 462 | |
| 463 | return false |
| 464 | } |
| 465 | |
| 466 | // reverse reverses the order of the point in a path and returns it. |
| 467 | func (p path) reverse() path { |