// Slice returns a rectangular slice of the grid given by a range relative to
// the grid. If the range is out of bounds of the parent grid, it will be
// reduced to fit to the available space. The returned grid shares memory with
// the parent.
//
// This makes it easy to use relative coordinates when working with UI
// elements.
Slice returns a rectangular slice of the grid given by a range relative to
the grid. If the range is out of bounds of the parent grid, it will be
reduced to fit to the available space. The returned grid shares memory with
the parent.

This makes it easy to use relative coordinates when working with UI
elements.
// Slice returns a rectangular slice of the grid given by a range relative to // the grid . If the range is out of bounds of the parent grid it will be // reduced to fit to the available space . The returned grid shares memory with // the parent . // // This makes it easy to use relative coordinates when working with UI // elements .
func (gd Grid) Slice(rg Range) Grid {
	if rg.Min.X < 0 {
		rg.Min.X = 0
	}
	if rg.Min.Y < 0 {
		rg.Min.Y = 0
	}
	max := gd.Rg.Size()
	if rg.Max.X > max.X {
		rg.Max.X = max.X
	}
	if rg.Max.Y > max.Y {
		rg.Max.Y = max.Y
	}
	min := gd.Rg.Min
	rg.Min = rg.Min.Add(min)
	rg.Max = rg.Max.Add(min)
	return Grid{innerGrid{Ug: gd.Ug, Rg: rg}}
}
func ( gd Grid ) Slice ( rg Range ) Grid { if rg . Min . X < 0 { rg . Min . X = 0 } if rg . Min . Y < 0 { rg . Min . Y = 0 } max := gd . Rg . Size ( ) if rg . Max . X > max . X { rg . Max . X = max . X } if rg . Max . Y > max . Y { rg . Max . Y = max . Y } min := gd . Rg . Min rg . Min = rg . Min . Add ( min ) rg . Max = rg . Max . Add ( min ) return Grid { innerGrid { Ug : gd . Ug , Rg : rg } } }
Slice returns a rectangular slice of the grid given by a range relative to
the grid.
Slice returns a rectangular slice of the grid given by a range relative to the grid .