rectangle.go 336 B

1234567891011121314151617181920212223
  1. package rectangle
  2. type Rectangle struct {
  3. X float64
  4. Y float64
  5. W float64
  6. H float64
  7. }
  8. func New(x, y, w, h float64) Rectangle {
  9. r := Rectangle{ x, y, w, h }
  10. return r
  11. }
  12. func (rect Rectangle) X2() float64 {
  13. return rect.X + rect.W
  14. }
  15. func (rect Rectangle) Y2() float64 {
  16. return rect.Y + rect.H
  17. }