Add LineFeed method

This commit is contained in:
Sasha Koshka 2023-04-08 20:13:16 -04:00
parent 7ca2622c1e
commit 27507a33e6
1 changed files with 18 additions and 0 deletions

View File

@ -96,6 +96,23 @@ func (element *Grid) Set (point image.Point, cell Cell) {
element.cells[element.index(point)].clean = false
}
// LineFeed pushes all cells up by one line.
func (element *Grid) LineFeed () {
if element.cells == nil { return }
element.cells = element.cells[element.stride:]
var index int
for index = 0; index < len(element.cells) - element.stride; index ++ {
element.cells[index] = element.cells[index + element.stride]
element.cells[index].clean = false
}
for ; index < len(element.cells); index ++ {
element.cells[index] = gridCell { }
element.cells[index].initColor()
}
}
// Push pushes whatever changes were made to the grid to the screen.
func (element *Grid) Push () {
if !element.ignorePush {
@ -263,6 +280,7 @@ func (element *Grid) draw (force bool) (updatedRegion image.Rectangle) {
for index, cell := range element.cells {
if force || !cell.clean {
element.cells[index].clean = true
cellBounds := element.bound(index)
updatedRegion = updatedRegion.Union(cellBounds)
shapes.FillColorRectangle (