And returns the rectangle that is the overlap of both.
(q Rect)
| 591 | |
| 592 | // And returns the rectangle that is the overlap of both. |
| 593 | func (r Rect) And(q Rect) Rect { |
| 594 | x0 := math.Max(r.X0, q.X0) |
| 595 | y0 := math.Max(r.Y0, q.Y0) |
| 596 | x1 := math.Min(r.X1, q.X1) |
| 597 | y1 := math.Min(r.Y1, q.Y1) |
| 598 | if x1 <= x0 || y1 <= y0 { |
| 599 | return Rect{} |
| 600 | } |
| 601 | return Rect{x0, y0, x1, y1} |
| 602 | |
| 603 | } |
| 604 | |
| 605 | // ToPath converts the rectangle to a path. |
| 606 | func (r Rect) ToPath() *Path { |
no outgoing calls