From d163fb2a3dcfe64ef1e984cedaeade8c8d0fc4bc Mon Sep 17 00:00:00 2001 From: Charlie Brej Date: Tue, 20 Apr 2010 14:00:01 +0100 Subject: [PATCH] [script] Default to text color alpha of 1 if nothing was passed If NULL or no variable was passed, the aplha variable would be read as NaN which gets clamped to 0 so the text would be completely transparent. --- src/plugins/splash/script/script-lib-image.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/splash/script/script-lib-image.c b/src/plugins/splash/script/script-lib-image.c index b017dbdf..12c3278f 100644 --- a/src/plugins/splash/script/script-lib-image.c +++ b/src/plugins/splash/script/script-lib-image.c @@ -163,19 +163,20 @@ static script_return_t image_text (script_state_t *state, char *text = script_obj_hash_get_string (state->local, "text"); - /* These colour values are currently unused, but will be once label supports them */ + float alpha; float red = CLAMP(script_obj_hash_get_number (state->local, "red"), 0, 1); float green = CLAMP(script_obj_hash_get_number (state->local, "green"), 0, 1); float blue = CLAMP(script_obj_hash_get_number (state->local, "blue"), 0, 1); - float alpha = 1; alpha_obj = script_obj_hash_peek_element (state->local, "alpha"); - if (alpha_obj) + if (script_obj_is_number (alpha_obj)) { alpha = CLAMP(script_obj_as_number (alpha_obj), 0, 1); - script_obj_unref(alpha_obj); } + else + alpha = 1; + script_obj_unref(alpha_obj); if (!text) return script_return_obj_null ();