Skip to content

Instantly share code, notes, and snippets.

@theredstapler
Created June 6, 2016 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theredstapler/8ed2ce7749b34b165db7fed4737d8118 to your computer and use it in GitHub Desktop.
Save theredstapler/8ed2ce7749b34b165db7fed4737d8118 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="jquery.min.js"></script>
<script src="fabric.min.js"></script>
</head>
<body>
<canvas id="c" width="800" height="600"></canvas>
<input id="b" type="button" value="Go right" />
<script>
var canvas = new fabric.Canvas('c');
var rect = new fabric.Rect({
left: 150,
top: 150,
fill: 'red',
width: 200,
height:200,
angle:45
});
canvas.add(rect);
$("#b").click(function(){
rect.setLeft(rect.getLeft() + 10);
canvas.renderAll();
console.log("Left: " + rect.getLeft());
console.log("Top: " + rect.getTop());
console.log("Angle: " + rect.getAngle());
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment