diff --git a/scripts/modules/graphics.js b/scripts/modules/graphics.js index 5fdb8eb1..cc9fa104 100644 --- a/scripts/modules/graphics.js +++ b/scripts/modules/graphics.js @@ -127,6 +127,19 @@ graphics.is_image[prosperon.DOC] = ` :return: True if 'obj' has a .texture and a .rect property, indicating it's an image object. ` +graphics.texture_from_data = function(data) +{ + if (!(data instanceof ArrayBuffer)) return undefined + + var img = { + surface: graphics.make_texture(data) + } + render.load_texture(img) + decorate_rect_px(img) + + return img +} + graphics.texture = function texture(path) { if (typeof path !== 'string') { return path // fallback if already an image object diff --git a/tests/qr_drag.js b/tests/qr_drag.js index bbaff906..8778f653 100644 --- a/tests/qr_drag.js +++ b/tests/qr_drag.js @@ -77,9 +77,8 @@ function is_url(str) function parse_data(res) { - var data = res.data - console.log("DOWNLOAD DONE! size was " + data.byteLength) - console.log(res.type) + if (!res.type.startsWith('image')) return + img = graphics.texture_from_data(res.data) } $_.receiver(e => {