From aafd9b6c4b4fcb86fdfe984bc77c3c0e15c6c77b Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Tue, 20 Feb 2018 11:56:44 +0100 Subject: [PATCH] Made Grid.SetSize() a bit more powerful. --- grid.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/grid.go b/grid.go index 2eedffe..f9a8f51 100644 --- a/grid.go +++ b/grid.go @@ -114,11 +114,16 @@ func (g *Grid) SetColumns(columns ...int) *Grid { } // SetSize is a shortcut for SetRows() and SetColumns() where all row and column -// values are set to a value of 0. The cells of the resulting grid will -// therefore be evenly distributed. -func (g *Grid) SetSize(rows, columns int) *Grid { +// values are set to the given size values. See SetRows() for details on sizes. +func (g *Grid) SetSize(rows, columns, rowSize, columnSize int) *Grid { g.rows = make([]int, rows) + for index := range g.rows { + g.rows[index] = rowSize + } g.columns = make([]int, columns) + for index := range g.columns { + g.columns[index] = columnSize + } return g }