From: Dimitri John Ledkov Date: Tue, 10 Sep 2019 13:00:08 +0000 (+0100) Subject: script: Add image tile support. X-Git-Tag: 0.9.5~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa89dcdf5e183796c91e3d7e53b443fe276edf6a;p=thirdparty%2Fplymouth.git script: Add image tile support. Signed-off-by: Dimitri John Ledkov --- diff --git a/src/plugins/splash/script/script-lib-image.c b/src/plugins/splash/script/script-lib-image.c index 748e6d1e..c53e0b0e 100644 --- a/src/plugins/splash/script/script-lib-image.c +++ b/src/plugins/splash/script/script-lib-image.c @@ -146,6 +146,21 @@ static script_return_t image_scale (script_state_t *state, return script_return_obj_null (); } +static script_return_t image_tile (script_state_t *state, + void *user_data) +{ + script_lib_image_data_t *data = user_data; + ply_pixel_buffer_t *image = script_obj_as_native_of_class (state->this, data->class); + int width = script_obj_hash_get_number (state->local, "width"); + int height = script_obj_hash_get_number (state->local, "height"); + + if (image) { + ply_pixel_buffer_t *new_image = ply_pixel_buffer_tile (image, width, height); + return script_return_obj (script_obj_new_native (new_image, data->class)); + } + return script_return_obj_null (); +} + static script_return_t image_text (script_state_t *state, void *user_data) { @@ -255,6 +270,13 @@ script_lib_image_data_t *script_lib_image_setup (script_state_t *state, "width", "height", NULL); + script_add_native_function (image_hash, + "_Tile", + image_tile, + data, + "width", + "height", + NULL); script_add_native_function (image_hash, "GetWidth", image_get_width, diff --git a/src/plugins/splash/script/script-lib-image.script b/src/plugins/splash/script/script-lib-image.script index 00b1c19c..ab4b7cfe 100644 --- a/src/plugins/splash/script/script-lib-image.script +++ b/src/plugins/splash/script/script-lib-image.script @@ -14,6 +14,11 @@ Image.Scale = fun (width, height) return Image.Adopt (this._Scale(width, height)); }; +Image.Tile = fun (width, height) +{ + return Image.Adopt (this._Tile(width, height)); +}; + Image.Text = fun (text, red, green, blue, alpha, font, align) { return Image.Adopt (Image._Text (text, red, green, blue, alpha, font, align));