Message from discussion
How to add image on canvas with reveal prototype pattern
Received: by 10.68.213.106 with SMTP id nr10mr3207881pbc.2.1335372826906;
Wed, 25 Apr 2012 09:53:46 -0700 (PDT)
X-BeenThere: fabricjs@googlegroups.com
Received: by 10.68.243.163 with SMTP id wz3ls835634pbc.3.gmail; Wed, 25 Apr
2012 09:53:46 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.68.218.103 with SMTP id pf7mr166208pbc.11.1335372826533; Wed,
25 Apr 2012 09:53:46 -0700 (PDT)
Authentication-Results: ls.google.com; spf=pass (google.com: domain of
rajinderraju...@gmail.com designates internal as permitted sender)
smtp.mail=rajinderraju...@gmail.com; dkim=pass
header...@gmail.com
Received: by ot8g2000pbb.googlegroups.com with HTTP; Wed, 25 Apr 2012 09:53:46
-0700 (PDT)
Date: Wed, 25 Apr 2012 09:53:46 -0700 (PDT)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0,gzip(gfe)
Message-ID: <da9def08-b809-4fdc-bf76-e349e7c5d0dd@ot8g2000pbb.googlegroups.com>
Subject: How to add image on canvas with reveal prototype pattern
From: gd singh <rajinderraju...@gmail.com>
To: "fabric.js" <fabricjs@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi
I am using following code to add image to canvas.
var Draw= function(){
// variable defined here
this.canvas = new fabric.Canvas('canvas');
this.drawingObject = null;
};
Draw.prototype = function(){
createImage= function(imgSrc){
//img = new fabric.Image({width:100,height:200,fromURL:'images/to-
do-list.jpg'});
// cannot I use the above code
fabric.Image.fromURL(imgSrc, function(img) {
img.scale(Math.random(0.1, 0.25)).setCoords();
img.set({ left: 200, top: 200});
});
// this function should return the img but I am not able to do so
},
draw= function(object,canvas){
if(!canvas){
this.canvas.add(object);
}else{
canvas.add(object);
}
};
return {
createImage:createImage,
draw:draw
};
}();
var t = new Draw();
img = t.createImage('images/to-do-list.jpg'); // this function should
return img