var srcImg = "http://fabricjs.com/lib/pug.jpg";
// canvas
var canvas = new fabric.Canvas('c');
canvas.backgroundColor = "#F5F5F5";
var redToOrangeGradient = {
x1: "50%", // For a vertical gradient, the x1 & y1 don't matter as long as they are the same
y1: "0%", // The top of the gradient will be at the top of the object
x2: "50%",
y2: "100%", // The bottom of the gradient will be at the bottom of the object
colorStops: {
0: "#FF0000",
1: "#FFFF00"
}
};
// circle
var circle = new fabric.Circle({
left: 50,
top: 50,
radius: 25,
fill: redToOrangeGradient
});
circle.set("hasRotatingPoint", true);
canvas.add(circle);
// text
var text = new fabric.Text('Text', {
left: 110,
top: 110
});
text.set("hasRotatingPoint", true);
canvas.add(text);
// image
fabric.util.loadImage(srcImg, function(img) {
var object = new fabric.Image(img);
object.set({
left: 200,
top: 200
});
object.set("hasRotatingPoint", true);
object.set("scaleX", .25);
object.set("scaleY", .25);
canvas.add(object);
canvas.renderAll();
});
canvas.renderAll();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.