Merge pull request #798 from rigrig/layout-img-object

Layout: add support for "img" with object or ArrayBuffer Graphics object
pull/816/head^2
Gordon Williams 2021-09-20 10:14:16 +01:00 committed by GitHub
commit 50ec8d970e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -308,9 +308,15 @@ Layout.prototype.update = function() {
l._h = 24;
l._w = 14 + l.label.length*8;
}, "img": function(l) {
var im = E.toString(l.src());
var src = l.src();
if (typeof(src) === 'object') {
l._h = ("width" in src) ? src.width : src.getWidth();
l._w = ("height" in src) ? src.height : src.getHeight();
} else {
var im = E.toString(src);
l._h = im.charCodeAt(0);
l._w = im.charCodeAt(1);
}
}, "": function(l) {
// size should already be set up in width/height
l._w = 0;