Transform transforms the rectangle by affine transformation matrix m and returns the new bounds of that rectangle.
(m Matrix)
| 436 | |
| 437 | // Transform transforms the rectangle by affine transformation matrix m and returns the new bounds of that rectangle. |
| 438 | func (r Rect) Transform(m Matrix) Rect { |
| 439 | p0 := m.Dot(Point{r.X0, r.Y0}) |
| 440 | p1 := m.Dot(Point{r.X1, r.Y0}) |
| 441 | p2 := m.Dot(Point{r.X1, r.Y1}) |
| 442 | p3 := m.Dot(Point{r.X0, r.Y1}) |
| 443 | x0 := math.Min(p0.X, math.Min(p1.X, math.Min(p2.X, p3.X))) |
| 444 | y0 := math.Min(p0.Y, math.Min(p1.Y, math.Min(p2.Y, p3.Y))) |
| 445 | x1 := math.Max(p0.X, math.Max(p1.X, math.Max(p2.X, p3.X))) |
| 446 | y1 := math.Max(p0.Y, math.Max(p1.Y, math.Max(p2.Y, p3.Y))) |
| 447 | return Rect{x0, y0, x1, y1} |
| 448 | } |
| 449 | |
| 450 | // Add returns a rect that encompasses both the current rect and the given rect. |
| 451 | func (r Rect) Add(q Rect) Rect { |