I created a custom stock-tool for drawing a rectangle, which can be seen at the following jsfiddle. The rectangle feature in my code works as I want to (it\'s drawn properly