// Resize is similar to Slice, but it only specifies new dimensions, and if the
// range goes beyond the underlying original grid range, it will grow the
// underlying grid. In case of growth, it preserves the content, and new cells
// are initialized to Cell{Rune: ' '}.
Resize is similar to Slice, but it only specifies new dimensions, and if the
range goes beyond the underlying original grid range, it will grow the
underlying grid. In case of growth, it preserves the content, and new cells
are initialized to Cell{Rune: ' '}.
// Resize is similar to Slice but it only specifies new dimensions and if the // range goes beyond the underlying original grid range it will grow the // underlying grid . In case of growth it preserves the content and new cells // are initialized to Cell { Rune : ' ' } .
func (gd Grid) Resize(w, h int) Grid {
	max := gd.Size()
	ow, oh := max.X, max.Y
	if ow == w && oh == h {
		return gd
	}
	if w <= 0 || h <= 0 {
		gd.Rg.Max = gd.Rg.Min
		return gd
	}
	if gd.Ug == nil {
		gd.Ug = &grid{}
	}
	gd.Rg.Max = gd.Rg.Min.Shift(w, h)
	if w+gd.Rg.Min.X > gd.Ug.Width || h+gd.Rg.Min.Y > gd.Ug.Height {
		ngd := NewGrid(w+gd.Rg.Min.X, h+gd.Rg.Min.Y)
		ngd.Copy(Grid{innerGrid{Ug: gd.Ug, Rg: NewRange(0, 0, gd.Ug.Width, gd.Ug.Height)}})
		*gd.Ug = *ngd.Ug
	}
	return gd
}
func ( gd Grid ) Resize ( w , h int ) Grid { max := gd . Size ( ) ow , oh := max . X , max . Y if ow == w && oh == h { return gd } if w <= 0 || h <= 0 { gd . Rg . Max = gd . Rg . Min return gd } if gd . Ug == nil { gd . Ug = & grid { } } gd . Rg . Max = gd . Rg . Min . Shift ( w , h ) if w + gd . Rg . Min . X > gd . Ug . Width || h + gd . Rg . Min . Y > gd . Ug . Height { ngd := NewGrid ( w + gd . Rg . Min . X , h + gd . Rg . Min . Y ) ngd . Copy ( Grid { innerGrid { Ug : gd . Ug , Rg : NewRange ( 0 , 0 , gd . Ug . Width , gd . Ug . Height ) } } ) * gd . Ug = * ngd . Ug } return gd }
Resize is similar to Slice, but it only specifies new dimensions, and if the
range goes beyond the underlying original grid range, it will grow the
underlying grid.
Resize is similar to Slice but it only specifies new dimensions and if the range goes beyond the underlying original grid range it will grow the underlying grid .