diff --git a/common/basetilecreator.go b/common/basetilecreator.go index 9abaeb2..264ee6c 100644 --- a/common/basetilecreator.go +++ b/common/basetilecreator.go @@ -52,14 +52,13 @@ var BackgroundColor = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} type BaseTileUpdateFunc func(x, y int, hash []byte) bool type BaseTileCreator struct { - client *RedisClient - colors *Colors - renderer *Renderer - yOrder *YOrder - yMin int16 - yMax int16 - baseDir string - //update BaseTileUpdateFunc + client *RedisClient + colors *Colors + renderer *Renderer + yOrder *YOrder + yMin int16 + yMax int16 + baseDir string emptyImage []byte bg color.RGBA } @@ -71,7 +70,7 @@ func NewBaseTileCreator( yMin, yMax int16, transparent bool, baseDir string) *BaseTileCreator { - //update BaseTileUpdateFunc) *BaseTileCreator { + renderer := NewRenderer(tileWidth, tileHeight, transparent) yMin, yMax = Order16(yMin, yMax) btc := &BaseTileCreator{ @@ -83,7 +82,6 @@ func NewBaseTileCreator( yMax: yMax, baseDir: baseDir, } - //update: update} btc.yOrder = NewYOrder(btc.renderBlock, yOrderCapacity) return btc } @@ -168,6 +166,9 @@ func (btc *BaseTileCreator) blankImage() []byte { return btc.emptyImage } +// WriteFunc returns a function intended to be run in background so +// the creation of the next tile with this creator can be done +// concurrently. func (btc *BaseTileCreator) WriteFunc(i, j int, update BaseTileUpdateFunc) func() (bool, error) { path := filepath.Join(btc.baseDir, strconv.Itoa(i), strconv.Itoa(j)+".png")