Little code cleanups.

This commit is contained in:
Sascha L. Teichmann 2014-09-12 10:45:36 +02:00
parent 6306a9acb7
commit f6f5aa0dd1

View File

@ -24,10 +24,6 @@ type Renderer struct {
Rejected int
}
const (
invalid = math.MinInt32 + 1
)
func NewRenderer(xOfs, zOfs int16, width, height int) (renderer *Renderer) {
dim := width * height
pixSize := dim * 16 * 16
@ -68,7 +64,6 @@ func (r *Renderer) RenderBlock(block *common.Block, nameIndex map[string]int32)
// is already filled and the block is strictly below.
blockY := int32(block.Coord.Y) << 4
pos := int(bz)*r.width + int(bx)
//fmt.Printf("pos: %d %d\n", pos, len(r.yMin))
if blockY < r.yMin[pos] {
r.Rejected++
return
@ -131,12 +126,14 @@ func (r *Renderer) CreateImage(colors []color.RGBA, background color.RGBA) *imag
}
func safeColor(x int32) uint8 {
if x < 0 {
x = 0
} else if x > 255 {
x = 255
}
switch {
case x < 0:
return 0
case x > 255:
return 255
default:
return uint8(x)
}
}
func (r *Renderer) CreateShadedImage(colors []color.RGBA, background color.RGBA) *image.RGBA {