pixeldos/part.go

22 lines
557 B
Go
Raw Permalink Normal View History

2018-12-30 07:36:29 +01:00
package main
import (
log "github.com/sirupsen/logrus"
)
2018-12-31 23:59:33 +01:00
func getPart(pixelmatrix [][][4]uint32, partCount, partTotal, partBegin int) ([][][4]uint32, int, int) {
2018-12-30 07:36:29 +01:00
xLength := len(pixelmatrix)
if xLength < partTotal {
log.Fatal("more parts then rows not possible")
2018-12-31 23:59:33 +01:00
return nil, 0, 0
2018-12-30 07:36:29 +01:00
}
2018-12-31 23:59:33 +01:00
partStep := (xLength / partTotal)
start := partBegin * partStep
2018-12-30 07:36:29 +01:00
// last part should return last rows
if partBegin + partCount == partTotal {
2018-12-31 23:59:33 +01:00
return pixelmatrix[start: ], start, 0
2018-12-30 07:36:29 +01:00
}
2018-12-31 23:59:33 +01:00
return pixelmatrix[ start : (partBegin + partCount) * partStep], start, 0
2018-12-30 07:36:29 +01:00
}