From 873843ee540595a886919a39554835bfe26e2f58 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Wed, 27 Feb 2019 17:36:30 +0100 Subject: [PATCH] transparency flag --- server/app/config.go | 2 ++ server/mapblockrenderer/renderer.go | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/server/app/config.go b/server/app/config.go index 01256a9..ec771a7 100644 --- a/server/app/config.go +++ b/server/app/config.go @@ -13,6 +13,7 @@ type Config struct { Port int `json:"port"` EnablePrometheus bool `json:"enableprometheus"` EnableRendering bool `json:"enablerendering"` + EnableTransparency bool `json:"enabletransparency"` Webdev bool `json:"webdev"` WebApi *WebApiConfig `json:"webapi"` Layers []*layer.Layer `json:"layers"` @@ -133,6 +134,7 @@ func ParseConfig(filename string) (*Config, error) { Port: 8080, EnableRendering: true, EnablePrometheus: true, + EnableTransparency: true, Webdev: false, WebApi: &webapi, Layers: layers, diff --git a/server/mapblockrenderer/renderer.go b/server/mapblockrenderer/renderer.go index c389499..9f46952 100644 --- a/server/mapblockrenderer/renderer.go +++ b/server/mapblockrenderer/renderer.go @@ -15,16 +15,18 @@ import ( ) type MapBlockRenderer struct { - accessor *mapblockaccessor.MapBlockAccessor - colors *colormapping.ColorMapping - enableShadow bool + accessor *mapblockaccessor.MapBlockAccessor + colors *colormapping.ColorMapping + enableShadow bool + enableTransparency bool } func NewMapBlockRenderer(accessor *mapblockaccessor.MapBlockAccessor, colors *colormapping.ColorMapping) *MapBlockRenderer { return &MapBlockRenderer{ - accessor: accessor, - colors: colors, - enableShadow: true, + accessor: accessor, + colors: colors, + enableShadow: true, + enableTransparency: false, } } @@ -211,12 +213,12 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *coords.MapBlockCoords) (*image.NRG imgX+IMG_SCALE, imgY+IMG_SCALE, ) - if c.A != 0xFF { + if c.A != 0xFF || !r.enableTransparency { //not transparent, mark as rendered foundBlocks++ xzOccupationMap[x][z] = true } - + draw.Draw(img, rect, &image.Uniform{c}, image.ZP, draw.Src) if foundBlocks == EXPECTED_BLOCKS_PER_FLAT_MAPBLOCK {