rectangle.go 344 B

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