Add LineFeed method
This commit is contained in:
parent
7ca2622c1e
commit
27507a33e6
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue