diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-05-22 19:52:24 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-05-22 19:53:23 +0100 |
commit | daed553a06716328366f5ea1a2ba09ba4872de1d (patch) | |
tree | 7c0f232cf242cd5dd83ca10cee2e22618a67208c /content/handlers/javascript/duktape/ImageData.bnd | |
parent | 244c49df26ba943dc7cef60413126fbaf52a4428 (diff) | |
download | netsurf-daed553a06716328366f5ea1a2ba09ba4872de1d.tar.gz netsurf-daed553a06716328366f5ea1a2ba09ba4872de1d.tar.bz2 |
javascript: Support Canvas to a basic level
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/javascript/duktape/ImageData.bnd')
-rw-r--r-- | content/handlers/javascript/duktape/ImageData.bnd | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/content/handlers/javascript/duktape/ImageData.bnd b/content/handlers/javascript/duktape/ImageData.bnd new file mode 100644 index 000000000..17673d92a --- /dev/null +++ b/content/handlers/javascript/duktape/ImageData.bnd @@ -0,0 +1,44 @@ +/* HTML canvas ImageData objects + * + * Copyright 2020 Daniel Silverstone <dsilvers@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * Released under the terms of the MIT License, + * http://www.opensource.org/licenses/mit-license + */ + +class ImageData { + private int width; + private int height; + private uint8_t *data; +}; + +init ImageData(int width, int height) +%{ + priv->width = width; + priv->height = height; + priv->data = duk_push_buffer(ctx, width * height * 4, false); + duk_put_prop_string(ctx, 0, MAGIC(DATA)); + duk_pop(ctx); +%} + +getter ImageData::width() +%{ + duk_push_int(ctx, priv->width); + return 1; +%} + +getter ImageData::height() +%{ + duk_push_int(ctx, priv->height); + return 1; +%} + +getter ImageData::data() +%{ + duk_push_this(ctx); + duk_get_prop_string(ctx, -1, MAGIC(DATA)); + duk_push_buffer_object(ctx, -1, 0, priv->width * priv->height * 4, DUK_BUFOBJ_UINT8CLAMPEDARRAY); + return 1; +%} |