fixed panic in Set method
This commit is contained in:
parent
88a6a466bf
commit
fbf90504b8
10
buffer.go
10
buffer.go
@ -30,9 +30,17 @@ func NewBuffer(width, height int) *Buffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) x(x int) int {
|
||||||
|
return limit(x, 0, b.width-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) y(y int) int {
|
||||||
|
return limit(y, 0, b.height-1)
|
||||||
|
}
|
||||||
|
|
||||||
// Set sets the rune at position (x,y) to c
|
// Set sets the rune at position (x,y) to c
|
||||||
func (b *Buffer) Set(x, y int, c rune) {
|
func (b *Buffer) Set(x, y int, c rune) {
|
||||||
b.data[y][x] = c
|
b.data[b.y(y)][b.x(x)] = c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the rune at position (x,y)
|
// Get returns the rune at position (x,y)
|
||||||
|
Loading…
Reference in New Issue
Block a user