0

Add support for 'alpha' option and change default

This commit is contained in:
Thomas Lake
2012-08-25 09:26:13 +01:00
parent c5a0687701
commit 06a7f6ebdc
2 changed files with 12 additions and 3 deletions

View File

@@ -212,6 +212,7 @@ class BiomeOverlay(Overlay):
name = "overlay-biomes" name = "overlay-biomes"
options = { options = {
'biomes' : ('a list of (biome, (r, g, b)) tuples for coloring biomes', None), 'biomes' : ('a list of (biome, (r, g, b)) tuples for coloring biomes', None),
'alpha' : ('an integer value between 0 (transparent) and 255 (opaque)', None),
} }
class Hide(RenderPrimitive): class Hide(RenderPrimitive):

View File

@@ -84,9 +84,8 @@ static void get_color(void *data, RenderState *state,
*g = biomes[i].g; *g = biomes[i].g;
*b = biomes[i].b; *b = biomes[i].b;
tmp = (128 - y_max + y) * 2 - 40; *a = self->parent.color->a;
*a = MIN(MAX(0, tmp), 255);
max_i = i; max_i = i;
break; break;
} }
@@ -98,6 +97,7 @@ static int
overlay_biomes_start(void *data, RenderState *state, PyObject *support) { overlay_biomes_start(void *data, RenderState *state, PyObject *support) {
PyObject *opt; PyObject *opt;
RenderPrimitiveBiomes* self; RenderPrimitiveBiomes* self;
unsigned char alpha_tmp=0;
/* first, chain up */ /* first, chain up */
int ret = primitive_overlay.start(data, state, support); int ret = primitive_overlay.start(data, state, support);
@@ -153,6 +153,14 @@ overlay_biomes_start(void *data, RenderState *state, PyObject *support) {
self->biomes = default_biomes; self->biomes = default_biomes;
} }
if (!render_mode_parse_option(support, "alpha", "b", &(alpha_tmp))) {
if (PyErr_Occurred()) {
PyErr_Clear();
alpha_tmp = 240;
}
self->parent.color->a = alpha_tmp;
}
/* setup custom color */ /* setup custom color */
self->parent.get_color = get_color; self->parent.get_color = get_color;