Kinetic.BackgroundText = function(config){ Kinetic.Group.call(this, config); this.data = config; this.bgColor = this.data.fill; this.txtColor = this.data.textFill; delete this.data.textFill; this.data.fill = this.txtColor; this.initBackgroundText(); } Kinetic.BackgroundText.prototype = { initBackgroundText: function(){ this.createBackgroundText(); }, createBackgroundText: function(){ this.label = new Kinetic.Text(this.data); console.log(this.data); this.bg = new Kinetic.Rect({ 'x': this.data.x, 'y': this.data.y, 'fill': this.bgColor, 'width': this.label.getWidth(), 'height': this.label.getHeight() }); console.log(this.bgColor); console.log(this.label.getWidth()); console.log(this.label.getHeight()); this.add(this.bg); this.add(this.label); }, setFill: function(color){ if (typeof this.bg != 'undefined'){ this.bg.fill(color); } } } Kinetic.Util.extend(Kinetic.BackgroundText, Kinetic.Group);