Added RectRel{,F,F32} methods.
- Instead of a second coordinate (x,y) you can provide the width & height of the rectangle.
This commit is contained in:
parent
cc72cd1171
commit
cc2addf7e2
@ -16,6 +16,11 @@ func Rect(x0, y0, x1, y1 int) Rectangle {
|
||||
return Rectangle{Point{x0, y0}, Point{x1, y1}}
|
||||
}
|
||||
|
||||
// RectRel is a shorthand function to create a rectangle specifying its width and height instead of a second coordinate.
|
||||
func RectRel(x, y, w, h int) Rectangle {
|
||||
return Rectangle{Point{x, y}, Point{x + w, y + h}}
|
||||
}
|
||||
|
||||
// Add translates rectangle r by point p.
|
||||
func (r Rectangle) Add(p Point) Rectangle {
|
||||
return Rectangle{
|
||||
|
@ -17,6 +17,11 @@ func RectF(x0, y0, x1, y1 float64) RectangleF {
|
||||
return RectangleF{PtF(x0, y0), PtF(x1, y1)}
|
||||
}
|
||||
|
||||
// RectRelF is a shorthand function to create a rectangle specifying its width and height instead of a second coordinate.
|
||||
func RectRelF(x, y, w, h float64) RectangleF {
|
||||
return RectangleF{PointF{x, y}, PointF{x + w, y + h}}
|
||||
}
|
||||
|
||||
// Add translates rectangle r by point p.
|
||||
func (r RectangleF) Add(p PointF) RectangleF {
|
||||
return RectangleF{
|
||||
|
@ -17,6 +17,11 @@ func RectF32(x0, y0, x1, y1 float32) RectangleF32 {
|
||||
return RectangleF32{PtF32(x0, y0), PtF32(x1, y1)}
|
||||
}
|
||||
|
||||
// RectRelF32 is a shorthand function to create a rectangle specifying its width and height instead of a second coordinate.
|
||||
func RectRelF32(x, y, w, h float32) RectangleF32 {
|
||||
return RectangleF32{PointF32{x, y}, PointF32{x + w, y + h}}
|
||||
}
|
||||
|
||||
// Add translates rectangle r by point p.
|
||||
func (r RectangleF32) Add(p PointF32) RectangleF32 {
|
||||
return RectangleF32{
|
||||
|
Loading…
Reference in New Issue
Block a user