import "image" // create a rectangle with width 100 and height 50 r := image.Rect(0, 0, 100, 50)
import "image" r1 := image.Rect(0, 0, 50, 50) r2 := image.Rect(25, 25, 75, 75) // get the intersection of r1 and r2 intersection := r1.Intersect(r2)
import "image" img := // load some image size := img.Bounds().Size() // scale the image by 2x newSize := size.Mul(2) resizedRect := image.Rectangle{ Min: img.Bounds().Min, Max: img.Bounds().Min.Add(newSize), } resizedImg := image.NewRGBA(resizedRect)These examples demonstrate the use of the image.Rectangle struct in functions like Rect(), Intersect(), and Mul(). The Rectangle struct belongs to the Go image package.