I was wondering if it is possible to store an image as an attribute of a js object. For example, I currently have:
twitter = {h:35, w:35, x:0, y:0, src: "./twitter.png"};
tw = new Image;
tw.src = twitter.src;
and then later in the program
context.drawImage(tw, twitter.x, twitter.y, twitter.w, twitter.h);
but I was wondering if the image src can be combined into the twitter object, so that it can be called like so
context.drawImage(twitter.src, twitter.x, twitter.y, twitter.w, twitter.h);
Thanks,
Tom
context.drawImage(new Image().src=twitter.src, twitter.x, twitter.y, twitter.w, twitter.h);is worth a shot