2 * Copyright (c) 2012, Intel Corporation.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 ImageObject = function(ctx, args)
13 this.name = args.name;
15 this.img = args.image;
16 this.xLoc = args.xLoc;
17 this.yLoc = args.yLoc;
18 this.zLoc = args.zLoc == undefined ? 0 : args.zLoc;
19 this.width = args.width;
20 this.height = args.height;
22 this.textObj = args.text !== undefined ? new TextObject(this.ctx,{"text" : args.text, "xLoc" : (this.xLoc + (this.width / 2)), "yLoc" : (this.yLoc + (this.height / 2)), "zLoc" : (this.zLoc + 1), "template" : args.textTemplate}) : undefined;
23 this.visible = args.visible == undefined ? true : args.visible;
24 this.onClick = undefined;
26 /* Img shadow styles */
27 this.imgShadowOffsetX = args.imgShadowOffsetX;
28 this.imgShadowOffsetY = args.imgShadowOffsetY
29 this.imgShadowBlur = args.imgShadowBlur;
30 this.imgShadowColor = args.imgShadowColor;
33 ImageObject.prototype.update = function(args)
35 if (args.name) {this.name = args.name;}
36 if (args.img) {this.img = args.img;}
37 if (args.xLoc) {this.xLoc = args.xLoc;}
38 if (args.yLoc) {this.yLoc = args.yLoc;}
39 if (args.zLoc) {this.zLoc = args.zLoc;}
40 if (args.width) {this.width = args.width;}
41 if (args.height) {this.height = args.height;}
43 if (args.ctx) {this.ctx = ctx;}
44 if (args.text !== undefined) {this.textObj.update({"text" : args.text, "xLoc" : (args.xLoc + (args.width / 2)), "yLoc" : (args.yLoc + (args.height / 2)), "zLoc" : (args.zLoc + 1), "template" : args.textTemplate})}
45 if (args.visible) {this.visible = args.visible;}
46 if (args.onClick) {this.onClick = args.onClick;}
48 /* Img shadow styles */
49 if (args.shadowOffsetX) {this.shadowOffsetX = args.shadowOffsetX;}
50 if (args.shadowOffsetY) {this.shadowOffsetY = args.shadowOffsetY;}
51 if (args.shadowBlur) {this.shadowBlur = args.shadowBlur;}
52 if (args.shadowColor) {this.shadowColor = args.shadowColor;}
55 ImageObject.prototype.drawObj = function()
59 this.ctx.drawImage(this.img, this.xLoc, this.yLoc, this.width, this.height);
61 if (this.textObj != undefined)
62 this.textObj.drawObj();