From: Charlie Brej Date: Tue, 20 Apr 2010 13:00:01 +0000 (+0100) Subject: [script] Default to text color alpha of 1 if nothing was passed X-Git-Tag: 0.8.3~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d163fb2a3dcfe64ef1e984cedaeade8c8d0fc4bc;p=thirdparty%2Fplymouth.git [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. --- 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 ();