some tools for diagrams in software documentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clear canvas | |
canvas.clear(); | |
// add red rectangl | |
canvas.add(new fabric.Rect({ | |
width: 50, height: 50, left: 50, top: 50, fill: 'rgb(255,0,0)' | |
})); | |
canvas.add(new fabric.Rect({ | |
width: 50, height: 50, left: 110, top: 50, fill: 'rgb(255,0,0)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fabric.Canvas.prototype.getItem = function(id) { | |
var object = null, | |
objects = this.getObjects(); | |
for (var i = 0, len = this.size(); i < len; i++) { | |
if (objects[i].id && objects[i].id === id) { | |
object = objects[i]; | |
break; | |
} | |
} |