added support for zero-sized buffers

This commit is contained in:
Timon Ringwald 2022-04-02 17:33:52 +02:00
parent 157e4f302d
commit 3e2be025b3

View File

@ -102,8 +102,8 @@ func (b *Buffer[T]) Sub(x, y, w, h int) *Buffer[T] {
// sanitize inputs
x = limit(x, 0, b.width-1)
y = limit(y, 0, b.height-1)
w = limit(w, 1, b.width-x)
h = limit(h, 1, b.height-y)
w = limit(w, 0, b.width-x)
h = limit(h, 0, b.height-y)
// make slice references
data := make([][]T, h)