From: Charlie Brej Date: Tue, 23 Mar 2010 22:28:22 +0000 (+0000) Subject: [script] Allow alpha color component to be set when generating text images X-Git-Tag: 0.8.2~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6afeecaafe2a15164e7a296e3df198c77a98cb15;p=thirdparty%2Fplymouth.git [script] Allow alpha color component to be set when generating text images The Image.Text function now accepts an alpha parameter of the color used. If not set this will be assumed to be 1 (thus reverse compatible). --- diff --git a/src/plugins/splash/script/script-lib-image.c b/src/plugins/splash/script/script-lib-image.c index 15bfe879..b017dbdf 100644 --- a/src/plugins/splash/script/script-lib-image.c +++ b/src/plugins/splash/script/script-lib-image.c @@ -158,6 +158,7 @@ static script_return_t image_text (script_state_t *state, script_lib_image_data_t *data = user_data; ply_pixel_buffer_t *image; ply_label_t *label; + script_obj_t *alpha_obj; int width, height; char *text = script_obj_hash_get_string (state->local, "text"); @@ -166,12 +167,21 @@ static script_return_t image_text (script_state_t *state, 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) + { + alpha = CLAMP(script_obj_as_number (alpha_obj), 0, 1); + script_obj_unref(alpha_obj); + } + if (!text) return script_return_obj_null (); - + label = ply_label_new (); ply_label_set_text (label, text); - ply_label_set_color (label, red, green, blue, 1.0); + ply_label_set_color (label, red, green, blue, alpha); ply_label_show (label, NULL, 0, 0); width = ply_label_get_width (label); @@ -233,6 +243,7 @@ script_lib_image_data_t *script_lib_image_setup (script_state_t *state, "red", "green", "blue", + "alpha", NULL); script_obj_unref (image_hash); diff --git a/src/plugins/splash/script/script-lib-image.script b/src/plugins/splash/script/script-lib-image.script index 443e6ec5..015a2f50 100644 --- a/src/plugins/splash/script/script-lib-image.script +++ b/src/plugins/splash/script/script-lib-image.script @@ -14,9 +14,9 @@ Image.Scale = fun (width, height) return Image.Adopt (this._Scale(width, height)); }; -Image.Text = fun (text, red, green, blue) +Image.Text = fun (text, red, green, blue, alpha) { - return Image.Adopt (Image._Text (text, red, green, blue)); + return Image.Adopt (Image._Text (text, red, green, blue, alpha)); }; Image |= fun (filename)