2019-01-23 14:56:45 +03:00
|
|
|
package tilerenderer
|
|
|
|
|
|
|
|
import (
|
2019-01-23 15:13:32 +03:00
|
|
|
"bytes"
|
|
|
|
"image"
|
|
|
|
"image/color"
|
2019-01-23 14:56:45 +03:00
|
|
|
"image/draw"
|
|
|
|
"image/png"
|
|
|
|
)
|
|
|
|
|
2019-01-23 15:13:32 +03:00
|
|
|
func CreateBlankTile(c color.RGBA) []byte {
|
|
|
|
rect := image.Rectangle{
|
|
|
|
image.Point{0, 0},
|
|
|
|
image.Point{IMG_SIZE, IMG_SIZE},
|
|
|
|
}
|
2019-01-23 14:56:45 +03:00
|
|
|
|
2019-01-23 15:13:32 +03:00
|
|
|
img := image.NewNRGBA(rect)
|
|
|
|
draw.Draw(img, rect, &image.Uniform{c}, image.ZP, draw.Src)
|
2019-01-23 14:56:45 +03:00
|
|
|
|
2019-01-23 15:13:32 +03:00
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
png.Encode(buf, img)
|
2019-01-23 14:56:45 +03:00
|
|
|
|
2019-01-23 15:13:32 +03:00
|
|
|
return buf.Bytes()
|
2019-01-23 14:56:45 +03:00
|
|
|
}
|